News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Linking error with wxWidgets 2.7

Started by crackerizer, October 03, 2006, 08:14:34 AM

Previous topic - Next topic

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) Select

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


But after put the project in C:B workspace and config the options. I get these errors.

Code (cpp) Select

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**)'


Please check my build configuration if there is something i'm missing.

Code (cpp) Select

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


Thank you

rjmyst3

Quote-lwxmsw27u_core -lwxbase27u
Looks like you are linking to the unicode library.

QuotewxStringBase::InitWith(char const*,
But you are compiling with non-unicode functions.

Looks like you missed wxUSE_UNICODE in your preprocessor definitions.
Add this:
-DwxUSE_UNICODE
[url="http://wxformbuilder.org"]http://wxformbuilder.org[/url]

tiwag

Quote from: rjmyst3 on October 03, 2006, 01:05:58 PM
..Looks like you missed wxUSE_UNICODE in your preprocessor definitions.
Add this:
-DwxUSE_UNICODE

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?
[url="http://wxformbuilder.org"]http://wxformbuilder.org[/url]

crackerizer

#4
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  :(.

Pecan

Quote from: crackerizer on October 03, 2006, 03:53:41 PM
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?

//-- Full Compile Logging --
   Settings->Compiler and Debugger->"Other"->Compiler logging = "Full command line".

crackerizer

Thank you very much. it's SOLVED.

The problem is that there are the old object files in obj/ folder. C:B didn't recompile the source codes when i pressed 'play' button. After rebuild the codes, everything is ok now. Thank you.