Author Topic: mingw32 and Xrender  (Read 8720 times)

Offline alexo

  • Multiple posting newcomer
  • *
  • Posts: 21
mingw32 and Xrender
« on: February 12, 2016, 03:00:52 pm »
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:
Code
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 ?

« Last Edit: February 13, 2016, 11:04:52 am by alexo »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7699
    • My Best Post
Re: mingw32 and Xrender
« Reply #1 on: February 12, 2016, 04:20:41 pm »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline alexo

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: mingw32 and Xrender
« Reply #2 on: February 12, 2016, 08:10:55 pm »
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.
« Last Edit: February 12, 2016, 08:30:58 pm by alexo »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: mingw32 and Xrender
« Reply #3 on: February 12, 2016, 08:48:03 pm »
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!]

Offline alexo

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: mingw32 and Xrender
« Reply #4 on: February 12, 2016, 09:32:10 pm »
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?

Code
||=== 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

« Last Edit: February 12, 2016, 10:00:49 pm by alexo »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: mingw32 and Xrender
« Reply #5 on: February 13, 2016, 12:11:37 am »
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!]

Offline alexo

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: mingw32 and Xrender
« Reply #6 on: February 13, 2016, 10:58:49 am »
Ok, that are linker messages, but this is the build string

Code
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:

Code
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.

« Last Edit: February 13, 2016, 11:05:06 am by alexo »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: mingw32 and Xrender
« Reply #7 on: February 13, 2016, 11:11:50 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!]

Offline alexo

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: mingw32 and Xrender
« Reply #8 on: February 13, 2016, 04:31:25 pm »
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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: mingw32 and Xrender
« Reply #9 on: February 13, 2016, 05:00:22 pm »
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!]

Offline alexo

  • Multiple posting newcomer
  • *
  • Posts: 21
Re: mingw32 and Xrender
« Reply #10 on: February 13, 2016, 05:28:15 pm »
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.
« Last Edit: February 13, 2016, 05:43:08 pm by alexo »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: mingw32 and Xrender
« Reply #11 on: February 13, 2016, 06:03:51 pm »
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!]