Skip to content

WxWidgets:Troubleshooting

wsWidgets를 사용하는 도중 발생할 수 있는 문제점에 대하여 정리한다.

Undefined reference

정적 컴파일(SHARED=0)을 할 경우 아래와 같은 메시지가 출력될 수 있다.

gcc_lib/libwxmsw30u_core.a(corelib_app.o):app.cpp:(.text+0x5f52): undefined reference to `__imp_InitCommonControls'
gcc_lib/libwxmsw30u_core.a(corelib_app.o):app.cpp:(.text+0x5fa2): undefined reference to `__imp_OleUninitialize'

이럴 경우 아래와 같이 wxWidgets관련 라이브러리를 추가해야 한다.

-lwxexpat -lwxjpeg -lwxmsw30u -lwxmsw30u_gl -lwxpng -lwxregexu -lwxscintilla -lwxtiff -lwxzlib

또한 아래와 같이 추가 라이브러리가 필요할 수 있다.

-lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32

MinGW w64 Compile error

컴파일 도중 아래와 같은 오류가 발생된다.

cc1plus.exe has stopped working.

아래와 같은 환경으로 컴파일을 진행하였다.

  • wxWidgets 3.00
  • MinGW32-w64
  • GCC v4.8.1
  • MSYS-1.0.18

이에 대하여 PCH를 사용하라는 조언이 있다.

You have to be using Precompiled header (wxprec.h or in my case sdk_precomp.h CB header that normally includes wxprec.h) to see the problem.
Headers that seem directly required to trigger problem are
"wx/msw/wrapcctl.h" and any one on the below headers
<wx/choicdlg.h>, <wx/filedlg.h>, <wx/slider.h>, or <wx/textdlg.h>.
The problem seemed worse when I replaced "wx/msw/wrapcctl.h" with "wx/msw/wrapshl.h" to test if it also caused a problem.

관련된 이슈는 다음을 참조: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56926

In function _start: undefined reference to main

Linux계열에서 컴파일 에러 메세지로 아래와 같은 내용이 출력될 수 있다.

/usr/lib/gcc/x86_64-linux-gnu/4.4.3/../../../../lib/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'

main을 찾을 수 없다는 내용으로, 원인은 다양하게 있을 수 있지만 우선 아래와 같이 확인해야 한다.

  • IMPLEMENT_CLASS 또는 IMPLEMENT_APP과 같은 wxWidgets Entry Point 설정 여부를 확인.
  • IMPLEMENT_APP가 Namespace로 감쌓여 있지 않는지 확인: No namespace 여야 한다.
class Application : public wxApp {
// ...
};
IMPLEMENT_APP(Application)

C++11 linking

c++11로 컴파일하고 싶을 경우 아래와 같이 환경변수를 사용해야 한다.

CXXFLAGS="-stdlib=libc++ -std=c++11"
OBJCXXFLAGS="-stdlib=libc++ -std=c++11"
CPPFLAGS="-stdlib=libc++"
LDFLAGS="-stdlib=libc++"