Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Asuka'

macrumors newbie
Original poster
Dec 23, 2012
4
0
Paris, FRANCE
Hi everybody!

First, sorry if my english is bad, I'm french so I may do some mistakes! =)

I'm a student, and my school gave me the source code of a program, written in C.
I have to finish that one.

But this program is using X11 libraries, and we don't have these libs on Mac OSX since 10.5 or 10.6 right?
Whatever, my MBP is running on Mountain Lion, so I don't have these libs and XCode tells me:
#include <X11/Xlib.h>
-> X11/Xlib.h not found

So I've installed XQuartz, but I've the same issue! =/

I've read something that I should make an "External Build System" project and use my own build tool or something like that, but I don't understand how to do this... (I tried to install CMake, but what should I do next?)

Someone can explain me how to build my program?

Thanks for your attention, and merry christmas for the next days! =)

PS: Sorry again if my english is pretty bad
 

LPZ

macrumors 65816
Jul 11, 2006
1,221
2
Hi everybody!

I'm a student, and my school gave me the source code of a program, written in C.
I have to finish that one.

But this program is using X11 libraries, and we don't have these libs on Mac OSX since 10.5 or 10.6 right?
Whatever, my MBP is running on Mountain Lion, so I don't have these libs and XCode tells me:
#include <X11/Xlib.h>
-> X11/Xlib.h not found

So I've installed XQuartz, but I've the same issue! =/

If you installed XQuartz then the X11 headers and libraries are installed in /opt/X11. For example, the header Xlib.h is in /opt/X11/include/X11. You need to inform XCode where to find the header. You could try changing #include <X11/Xlib.h> to #include "/opt/X11/include/X11/Xlib.h" .

I don't use XCode, but another option would be to modify the path that XCode uses when searching for headers. You'll need to consult the XCode documentation, or wait for a more enlightened user to reply.
 

Platskies

macrumors member
Jul 24, 2012
52
44
NSW, Australia
I don't use XCode, but another option would be to modify the path that XCode uses when searching for headers. You'll need to consult the XCode documentation, or wait for a more enlightened user to reply.

I'm pretty sure you can do that by:
1. Selecting the Xcode project file in the Project Navigator (the left sidebar's folder icon)
2. Click the Build Settings tab
3. Find the "Header Search Paths" setting, and add /opt/X11/include
 

LPZ

macrumors 65816
Jul 11, 2006
1,221
2
I'm pretty sure you can do that by:
1. Selecting the Xcode project file in the Project Navigator (the left sidebar's folder icon)
2. Click the Build Settings tab
3. Find the "Header Search Paths" setting, and add /opt/X11/include

Thanks. This seems the right way to proceed. My earlier suggestion (to edit the source file) might help XCode find the one header file, but undoubtably Xlib.h will want to include additional header files, which will also need to be found.

I'm puzzled/curious about what kind of programming exercise this is, that needs to include X11 headers.
 

Asuka'

macrumors newbie
Original poster
Dec 23, 2012
4
0
Paris, FRANCE
Thanks for answering me, XCode now loads the libs!

But I have a new problem :

Xcode said:
Undefined symbols for architecture x86_64:
"_XCloseDisplay", referenced from:
_libererAffichage in affichage.o
"_XCreateGC", referenced from:
_initialiserAffichage in affichage.o
"_XCreateImage", referenced from:
_initialiserAffichage in affichage.o
"_XCreateSimpleWindow", referenced from:
_initialiserAffichage in affichage.o
"_XDefaultVisual", referenced from:
_initialiserAffichage in affichage.o
"_XDestroyWindow", referenced from:
_libererAffichage in affichage.o
"_XFlush", referenced from:
_initialiserAffichage in affichage.o
_afficherImage in affichage.o
_changerLigne in affichage.o
_changerBloc in affichage.o
"_XFreeGC", referenced from:
_libererAffichage in affichage.o
"_XMapWindow", referenced from:
_initialiserAffichage in affichage.o
"_XMoveWindow", referenced from:
_initialiserAffichage in affichage.o
"_XOpenDisplay", referenced from:
_initialiserAffichage in affichage.o
"_XPutImage", referenced from:
_afficherImage in affichage.o
_changerLigne in affichage.o
_changerBloc in affichage.o
"_XStoreName", referenced from:
_initialiserAffichage in affichage.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I don't know why I got this, I don't use any of these _Xnames in my code.
So, does this means that my X11 libraries are wrong? (I don't think so)

@LPZ: This is a program to smooth a picture.
 
Last edited:

LPZ

macrumors 65816
Jul 11, 2006
1,221
2
Thanks for answering me, XCode now loads the libs!

But I have a new problem :



I don't know why I got this, I don't use any of these _Xnames in my code.
So, does this means that my X11 libraries are wrong? (I don't think so)

@LPZ: This is a program to smooth a picture.

Seems like the affichage.o you are linking is an i386 (32 bit) object file and your system needs an x86_64 (64 bit) version. The affichage.o available here is 64 bit; perhaps it is what you need.
 

Asuka'

macrumors newbie
Original poster
Dec 23, 2012
4
0
Paris, FRANCE
Thanks, but this is not the file I need.

I don't think the issue is about a 32 or 64 bits version, I tried to compile my program in 32 bits and I get a similar error:
Undefined symbols for architecture i386:
...
ld: symbol(s) not found for architecture i386

Moreover, my teachers didn't give me *.o objects, but gave me the *.c/*.h files, so XCode makes the *.o itself.
 

LPZ

macrumors 65816
Jul 11, 2006
1,221
2
Thanks, but this is not the file I need.

I don't think the issue is about a 32 or 64 bits version, I tried to compile my program in 32 bits and I get a similar error:


Moreover, my teachers didn't give me *.o objects, but gave me the *.c/*.h files, so XCode makes the *.o itself.

So you are compiling a program named affichage.c to produce affichage.o? Perhaps XCode simply cannot find the X11 libraries? It seems to have found the headers.
 

Asuka'

macrumors newbie
Original poster
Dec 23, 2012
4
0
Paris, FRANCE
My program is made of several .c, but affichage.c is the only one that use X11 libs.
I don't know why XCode doesn't find the libs, I have added '/opt' recursively under LIBRARY SEARCH PATH to be sure that Xcode find them, but maybe I'm wrong!


EDIT: I reached to make it worked, I need to add "-lX11" during the building.
This works in the Terminal, but I can't find where add this option under XCode =/
 
Last edited:

Madd the Sane

macrumors 6502a
Nov 8, 2010
534
73
Utah
Look at additional linker flags. Or you could add the X11 library to the Xcode project and tell the project to link to it.

You might also need to set the library search path if you haven't already done that.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.