News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

mingw32 and Xrender

Started by alexo, February 12, 2016, 03:00:52 PM

Previous topic - Next topic

alexo

hello forum,
I'm trying to cross compile with mingw32.
When I try to compile a hello world toy program I get a build log message saying the linker cannot find the Xrender lib.

this is the build instruction automatically given by the compile project button:

i586-mingw32msvc-g++ -I/usr/local/include -I/usr/include/freetype2 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT -g -I/usr/i586-mingw32msvc/bin -c /home/alessandro/Documenti/ProgC/AVOrder/main.cpp -o obj/Debug/main.o
i586-mingw32msvc-g++ -L/usr/i586-mingw32msvc/lib -o bin/Debug/AVOrder obj/Debug/main.o  /usr/local/lib/libfltk.a -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 

/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/../../../../i586-mingw32msvc/bin/ld: cannot find -lXrender


how can I strip this lib from the compiler build string ?


stahta01

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

alexo

#2
where can I modify the build and linker string?

I'm sorry but I can't see how to edit those lines. They are automatically built.

oBFusCATed

Project -> Build options -> <your target> -> Linker
and/or
Project -> Build options -> <your target> -> Search paths -> Linker.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

alexo

#4
Both those fields are empty. But in compilation I still get those long list of library links.
I added the path to the folder containing the libXrender in the project->build options->search-directories->Linker tab  and now it works.

Now I have a new problem.
I'm trying to build a FLTK program for the windows platform. No problems building it with gcc for linux.
The trouble is that the compiler complains she can find the header files with the function definitions.
How do I insert the folder where to find these header files?

||=== Build: Debug in FLTK_Test (compiler: MingW32) ===|
obj/Debug/main.o:main.cpp|| undefined reference to `Fl_Window::Fl_Window(int, int, char const*)'|
obj/Debug/main.o:main.cpp|| undefined reference to `Fl_Box::Fl_Box(int, int, int, int, char const*)'|
obj/Debug/main.o:main.cpp|| undefined reference to `Fl_Group::end()'|
obj/Debug/main.o:main.cpp|| undefined reference to `Fl_Window::show(int, char**)'|
obj/Debug/main.o:main.cpp|| undefined reference to `Fl::run()'|
||=== Build failed: 5 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|


Thank you


oBFusCATed

Obviously it is not the compiler that is complaining, but the linker.
And obviously you have to link to the proper libs.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

alexo

#6
Ok, that are linker messages, but this is the build string


i586-mingw32msvc-g++ -I/usr/local/include -I/usr/include/freetype2 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT  -c /home/alessandro/Documenti/ProgC/FLTK_Test/main.cpp -o obj/Debug/main.o
i586-mingw32msvc-g++ -L/usr/lib/i386-linux-gnu -L/usr/local/lib -L/home/alessandro/Scaricati/fltk-1.3.x-r11080/lib -L/usr/i586-mingw32msvc/lib -o bin/Debug/FLTK_Test obj/Debug/main.o /usr/local/lib/libfltk.a -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11  /usr/lib/i386-linux-gnu/libXrender.a
obj/Debug/main.o:main.cpp:(.text+0x7d): undefined reference to `Fl_Window::Fl_Window(int, int, char const*)'
obj/Debug/main.o:main.cpp:(.text+0xbf): undefined reference to `Fl_Box::Fl_Box(int, int, int, int, char const*)'
obj/Debug/main.o:main.cpp:(.text+0x125): undefined reference to `Fl_Group::end()'
obj/Debug/main.o:main.cpp:(.text+0x13e): undefined reference to `Fl_Window::show(int, char**)'
obj/Debug/main.o:main.cpp:(.text+0x146): undefined reference to `Fl::run()'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
5 error(s), 0 warning(s) (0 minute(s), 0 second(s))


the library fltk.a in /usr/local/lib is already present in the build string but I still have errors.
Isn't it an error due to the fact that the #include file are not found?

This is the working build string used by the gnu gcc compiler:


g++ -I/usr/local/include -I/usr/include/freetype2 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT -g  -c /home/alessandro/Documenti/ProgC/Inserimento_ordine_client/main.cpp -o obj/Debug/main.o
g++  -o bin/Debug/Inserimento_ordine_client obj/Debug/main.o  /usr/local/lib/libfltk.a -lXrender -lXcursor -lXfixes -lXext -lXft -lfontconfig -lXinerama -lpthread -ldl -lm -lX11 


it is neater and less messed up.
I am not able to manually edit them. I've tryed to add the library path in every project build option's linker field but nothing happpened.


oBFusCATed

Quote from: alexo on February 13, 2016, 10:58:49 AM
Isn't it an error due to the fact that the #include file are not found?
No, these are linker errors. Linkers don't read includes or sources.
They work with object files, static libraries (archives of object files) and shared libraries.

The problem you're having is that you're trying to use a native gcc built library with the mingw-gcc compiler.
So you want to use a linux library to produce a windows executable. This won't work by design.
You need to rebuild every library you want to use with mingw-gcc compiler.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

alexo

And you are a genious,
I hadn't the faintest idea that could be the problem.

I'll try to compile the lib and I'll let you know. Cross compilation without external libraries work perfectly.

But, I think I've found a bug in the 16.01 version of C::B.

I obtain it after trying to remove clicking Delete a manually installed  compiler (via the copy button).
Or at least this is the trouble I'm getting trying to remove Mingw and willing to reinstall it freshly.

Anyway, thank you oBFusCATed

oBFusCATed

What are the exact steps needed to reproduce this?
Can you expand the backtrace and post it?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

alexo

#10
The steps where

1 - install MingW32
2 - click Copy button to add a new compiler
3 - configure everything for the compiler
4 - click Delete to remove Mingw

I'll post the backtrace as text file.
Hope it may help.

oBFusCATed

Thanks. Fixed in trunk/master.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]