Linking step: Lib directories missing and other questions Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
marinoernestoch
Earned a small fee
Earned a small fee
Posts: 10
Joined: Tue Aug 18, 2020 2:16 pm

Linking step: Lib directories missing and other questions

Post by marinoernestoch » Thu Aug 20, 2020 12:58 pm

Good morning.
Today I reinstalled wxWidgets following PB's instructions / suggestions.
The cd install and variable are:

Code: Select all

C:\wxWidgets-3.1.4>set wxwin
WXWIN=C:\wxWidgets-3.1.4
The options were:

Code: Select all

mingw32-make -f makefile.gcc  -j4 SHARED=0 UNICODE=1 BUILD=debug   CXXFLAGS="-std=c++17" LDFLAGS="-static"
I tested minimal and it went well.
I have defined a new non-DLL, non-Monolitic, Unicode enabled wxWidhgets project with debug target GUI Mode Application. I have not specified additional libraries.
The compilation went well but the linker did not.
This is the partial log.

Code: Select all

-------------- Build: Debug in fine (compiler: CTDM-GCC-64)---------------

g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -g -IC:\wxWidgets-3.1.4\include -IC:\wxWidgets-3.1.4\lib\gcc_lib\mswud -IC:\wxWidgets-3.1.4\include -c E:\Dati_Marino\A_AmbienteProva_NON_salvare\Code_Blocks_C++\fine\fineApp.cpp -o obj\Debug\fineApp.o
g++.exe -pipe -mthreads -D__GNUWIN32__ -D__WXMSW__ -DwxUSE_UNICODE -Wall -g -IC:\wxWidgets-3.1.4\include -IC:\wxWidgets-3.1.4\lib\gcc_lib\mswud -IC:\wxWidgets-3.1.4\include -c E:\Dati_Marino\A_AmbienteProva_NON_salvare\Code_Blocks_C++\fine\fineMain.cpp -o obj\Debug\fineMain.o
g++.exe -LC:\wxWidgets-3.1.4\lib\gcc_lib\mswud -LC:\wxWidgets-3.1.4\lib\gcc_lib -LC:\CTDM-GCC-64\lib -o bin\Debug\fine.exe obj\Debug\fineApp.o obj\Debug\fineMain.o  obj\Debug\resource.res -mthreads  -lwxmsw31u_core -lwxbase31u -lwxpng -lwxzlib -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lcomctl32 -lwsock32 -lodbc32 -lshlwapi -lversion -loleacc -luxtheme -mwindows
C:/CTDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\wxWidgets-3.1.4\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0xb30): undefined reference to `jpeg_std_error'
C:/CTDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\wxWidgets-3.1.4\lib\gcc_lib/libwxmsw31u_core.a(corelib_imagjpeg.o):imagjpeg.cpp:(.text+0xb92): undefined reference to `jpeg_destroy_decompress'
.
.......
Process terminated with status 1 (1 minute(s), 57 second(s))
50 error(s), 0 warning(s) (1 minute(s), 57 second(s))
Included libraries are on the log (there is a redundancy).
Questions :?: ](*,) :
A) if I have installed the 64 bit version why does codebloks put me -D__GNUWIN32__ ?. Where do it get this definition ?;
B) if I defined static libraries at the project level and in "Toolchain executable - linker for static libs" is specified "ar.exe" because in the log I find g++ also in the link step?
C) Which libraries should I add to eliminate the "undefined reference to` jpeg_std_error '"....and others errors?
I searched the forum but came up with a lot of confused ideas.

I thank in advance whoever wants to help me.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2675
Joined: Sun Jan 03, 2010 5:45 pm

Re: Linking step: Lib directories missing and other questions

Post by PB » Thu Aug 20, 2020 2:14 pm

I think the error is pretty clear, you are missing the jpeg library: libwxjpeg.a.

__GNUWIN32__ being defined is OK, you are using so-called Win32 API, regardless of actual bitness of the binaries.

I think you should leave toolchain executables at their defaults, but perhaps it is different with TDM than other compilers. IIRC, TDM-GCC allowed building both 32- and 64-bit binaries, while other MinGW distributions cannot crossbuild, i.e., 32-bit toolchain produces 32-bit binaries, and 64-bit toolchain produced 64-bit binaries. But again, I have basically no knowledge of TDM-GCC...

marinoernestoch
Earned a small fee
Earned a small fee
Posts: 10
Joined: Tue Aug 18, 2020 2:16 pm

Re: Linking step: Lib directories missing and other questions

Post by marinoernestoch » Thu Aug 20, 2020 2:55 pm

Thanks Pb.
I think the error is pretty clear, you are missing the jpeg library: libwxjpeg.a.
At first I was ashamed. :? But then I said to myself: if I compiled the basic skeleton obtained from the definition of a new project, the basic libraries should have been included ...
__GNUWIN32__ being defined is OK,
OK
I think you should leave toolchain executables at their defaults,
These are values that the CodeBlock has set. I just checked that the .exe was present in the directory.

Anyway now I have many errors (more 50):

Code: Select all

........ 3.1.4\lib\gcc_lib\libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp|| undefined reference to `TIFFClientOpen'|
.........3.1.4\lib\gcc_lib\libwxmsw31u_core.a(corelib_imagtiff.o):imagtiff.cpp|| undefined reference to `TIFFSetWarningHandler'|
To avoid a further fool I searched and found a "something similar" in $(#wx)\src\tiff\libtiff.
but it seems strange to me that the link looks for something in a source.
In fact, the errors remained.. :(

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2675
Joined: Sun Jan 03, 2010 5:45 pm

Re: Linking step: Lib directories missing and other questions

Post by PB » Thu Aug 20, 2020 3:00 pm

I think it seems pretty obvious that you also need to add the tiff library: libwxtiff.a

BTW, if you want to do link the GCC runtime libs statically for the application, perhaps you should tell that to the compiler in Code::Blocks too (see chapter 4.6.3) otherwise the DLLs are still required for the executable.
Last edited by PB on Thu Aug 20, 2020 3:12 pm, edited 1 time in total.

marinoernestoch
Earned a small fee
Earned a small fee
Posts: 10
Joined: Tue Aug 18, 2020 2:16 pm

Re: Linking step: Lib directories missing and other questions

Post by marinoernestoch » Thu Aug 20, 2020 3:11 pm

Another error with wx_re .. or something like that.
So I entered libwxregexu.a and now it's finally OK.
You deserve a medal, at least for your patience. :D

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2675
Joined: Sun Jan 03, 2010 5:45 pm

Re: Linking step: Lib directories missing and other questions

Post by PB » Thu Aug 20, 2020 3:15 pm

The jpeg and tiff libraries are not needed in the shared build used in my guide, only in the static build.

The need for wxregex is also explained there: it was introduced in 3.1.4 and is again not needed in 3.1.5.

Post Reply