User forums > Help
Linking error with wxWidgets 2.7
crackerizer:
Hello,
I'm trying to build a very simple program with only a single frame with static library. Everything is fine with manual build. Here are the build commands i use.
--- Code: (cpp) ---g++ -c -o main.o -mthreads -D__WXMSW__ -D_UNICODE -O2 main.cpp
windres -ixYGx.rc -oxYGx.o --define __WXMSW__ --define _UNICODE
g++ -o xYGxHelper.exe main.o xYGx.o -mthreads -mwindows -lwxmsw27u_core -lwxbase27u -lwxtiff -lwxjpeg -lwxpng -lwxzlib -lwxregexu -lwxexpat -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lwsock32 -lodbc32
--- End code ---
But after put the project in C:B workspace and config the options. I get these errors.
--- Code: (cpp) ---obj\Release\main.o(.text+0x17b):main.cpp: undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
obj\Release\main.o(.text+0x1a3):main.cpp: undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
obj\Release\main.o(.text+0x3ba):main.cpp: undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
obj\Release\main.o(.text+0x672):main.cpp: undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
obj\Release\main.o(.text+0x693):main.cpp: undefined reference to `wxStringBase::InitWith(char const*, unsigned int, unsigned int)'
obj\Release\main.o(.rdata$_ZTV10xYGxHelper[vtable for xYGxHelper]+0x44):main.cpp: undefined reference to `wxApp::Initialize(int&, char**)'
--- End code ---
Please check my build configuration if there is something i'm missing.
--- Code: (cpp) ---Compile flag: -Wall -O2 -s
Other options: -mthreads -mwindows
Define:
__WXMSW__
_UNICODE
linking options (sort by order):
-mthreads
-Wl,--subsystem,windows
-mwindows
-lwxmsw27u_core
-lwxbase27u
-lwxtiff
-lwxjpeg
-lwxpng
-lwxzlib
-lwxregexu
-lwxexpat
-lkernel32
-luser32
-lgdi32
-lcomdlg32
-lwinspool
-lwinmm
-lshell32
-lcomctl32
-lole32
-loleaut32
-luuid
-lrpcrt4
-ladvapi32
-lwsock32
-lodbc32
--- End code ---
Thank you
rjmyst3:
--- Quote ----lwxmsw27u_core -lwxbase27u
--- End quote ---
Looks like you are linking to the unicode library.
--- Quote ---wxStringBase::InitWith(char const*,
--- End quote ---
But you are compiling with non-unicode functions.
Looks like you missed wxUSE_UNICODE in your preprocessor definitions.
Add this:
--- Code: ----DwxUSE_UNICODE
--- End code ---
tiwag:
--- Quote from: rjmyst3 on October 03, 2006, 01:05:58 pm ---..Looks like you missed wxUSE_UNICODE in your preprocessor definitions.
Add this:
--- Code: ----DwxUSE_UNICODE
--- End code ---
--- End quote ---
this is for shure not the problem, look in wx\platform.h:228-246 how these macros are used
either define UNICODE or _UNICODE or wxUSE_UNICODE=1
if you want to use the unicode wxlibs.
rjmyst3:
I stand corrected. Defining wxUSE_UNICODE does nothing - it has to be defined to a value, 0 or 1. Also, any of the UNICODE defines should work equally well, as long as wx/platform.h is included first - which it is by both wx/string.h (through wx/defs.h) and wx/wxchar.h.
However main.o was definitely compiled with wxChar typedef'd as char, which can only happen when wxUSE_UNICODE = 0.
See wx/string.h line 266 for the declaration of InitWith with wxChar, and wx/wxchar.h lines 181 and 182 for the typedef of wxChar.
Rebuild?
crackerizer:
Thank you for your fast responses.
I tried everything suggested here without luck.
As i stated that the manual build works fine with _UNICODE flag and i've defined it in C:B.
Is there any way i can see the raw build command?
and can this be C:B bug?? i dont see any mistake here. I've tried almost every possible configurations :(.
Navigation
[0] Message Index
[#] Next page
Go to full version