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

tennis.music

macrumors newbie
Original poster
Nov 10, 2006
3
0
I use Xcode2 on Mac OS X 10.4, and program c++ with GSL library.
The GSL header files are in /opt/local/include/gsl/gsl_xxx.h
I also edit the settings of "Header Search Path" to be /opt/local/include
and type
# include <gsl/gsl_xxx.h>
in my program.
But Xcode2 still cannot locate the file.

I am very sure the file is there and I didn't type it wrong. Sometimes Xcode2 can find it and build my program successfully, sometimes not. Looks completely random.

I am so tired of Xcode2. Can someone save me?
 
I use Xcode2 on Mac OS X 10.4, and program c++ with GSL library.
The GSL header files are in /opt/local/include/gsl/gsl_xxx.h
I also edit the settings of "Header Search Path" to be /opt/local/include
and type
# include <gsl/gsl_xxx.h>
in my program.
But Xcode2 still cannot locate the file.

I am very sure the file is there and I didn't type it wrong. Sometimes Xcode2 can find it and build my program successfully, sometimes not. Looks completely random.

I am so tired of Xcode2. Can someone save me?

Try putting a trailing "/" at the end of /opt/local/include in the header search path. It sounds stupid, I know, but I've had this issue with gcc compiler flags in my makefiles before.
 
I have tried, still not working.
I even try #include "gsl/gsl_rng.h" rather than #include <gsl/gsl_rng.h> .
I can't get it work.
The most interesting things is, it was working before. When I look at those working project's settings, the "user header searching path" is empty.
 
Xcode cannot find header file?

I have the same problem, just different files to access.

My project is in:
/Users/<username>/Development/testlibxmlxx

The header file (libxml++.h) I want to include is in:
/opt/local/include/libxml++-1.0/libxml++

My Header Search Paths in XCode is set to:
/opt/local/include/libxml++-1.0/**

In my CPP file I have:
#include <libxml++/libxml++.h>

When I compile I get the error:
"error: libxml++/libxml++.h: No such file or directory"

If the include line is as follows I get:
#include <libxml++/libxml++.h>
"error: libxml++.h: No such file or directory"

I am new to programming on the Mac with XCode, so sometimes I do not understand how things fit together.

Anyone with ideas?
 
I fight with this myself. I tried including the "ruby.h" header yesterday and could not get it to work.

I have two books on Xcode, and I don't think either do it justice for describing how to use and leverage it. Both books take on a "follow-the-bouncing-ball sample project" approach, and don't, IMHO, spend enough time on the underlying architecture of the IDE so that you can figure things out for yourself. I'll be watching this resurrected thread.
 
I have 3 books here:
Step into Xcode
Mac OS X Internals
Cross-Platform Development in C++

The problems I have are not mentioned in any of these books. :confused:

It is quite frustrating to work like this. I come from a Windows environment, where these type of things simply do not happen. Maybe I just knew Windows inside out! Coming over to Mac has been a very frustrating process, and leading the pack of frustration is Xcode. :mad:

Of course, with all this ranting and raving, I still do not have a solution, like so many others it seems! :(
 
I use Xcode2 on Mac OS X 10.4, and program c++ with GSL library.
The GSL header files are in /opt/local/include/gsl/gsl_xxx.h
I also edit the settings of "Header Search Path" to be /opt/local/include
and type
# include <gsl/gsl_xxx.h>
in my program.
But Xcode2 still cannot locate the file.

I am very sure the file is there and I didn't type it wrong. Sometimes Xcode2 can find it and build my program successfully, sometimes not. Looks completely random.

I am so tired of Xcode2. Can someone save me?

XCode 3 has been out for ages.

<these quotes> are for system header files.
"these quotes" are for user header files.

There is probably an option to use the header search path for all include files.

The usual method to get this working is to start with something that works and modify it until you get what you want. Remember that 99% of the time it is some stupid mistake or something you don't understand that keeps it from working.
 
I use Xcode 3 and whether I use <> for include files or "", the result is the same. :eek:

I am also using a test project with one .cpp file as follows:

#include <CoreFoundation/CoreFoundation.h>

#include <libxml++.h>
//Here I also used:
//#include <libxml++/libxml++.h>
//#include "libxml++.h"
//#include "libxml++/libxml++.h"

int main (int argc, const char * argv[]) {
// insert code here...
CFShow(CFSTR("Hello, World!\n"));
return 0;
}

This is the only code I have.

You can see in my post from above that I have set the Header Search Paths in Xcode. :cool:
 
Not completely certain this would work, but you could potentially use dtrace to watch for stat() and open() calls, and filter the output based on the filename in question. That could give you an idea of what path(s) it is looking for the header at, which might indicate what's going wrong.
 
Can it be true that there are no :apple: experts out there willing to help with this issue? :eek:

You'll probably need some basic debugging techniques.

Fact: You think it should work, but it doesn't work. So something is wrong somewhere. Most likely something you did, because otherwise there would be more people complaining. All you need to find is: What is wrong?

Start with something that works, then change it until it breaks, and find out why.

Start by including the full path:

#include "/opt/local/include/libxml++-1.0/libxml++/libxml++.h".

If that doesn't work: Start terminal, type

ls /opt/local/include/libxml++-1.0/libxml++

That should list the files in the directory. If libxml++.h isn't there, that's your problem. If the directory doesn't exist, try

ls /opt/local/include/libxml++-1.0

and so on. If that's the problem, fix it.

Move the file to some source directory. Check if it works. Try a header file in some different directory. Maybe it's the unusual characters (+ and -) in the path.
 
I do use Xcode 3 on Mac OS X 10.5. :D

The file definitely exists in the folder I specified above. :cool:

When I #include <complete header file path> then Xcode can't find the header files included by libxml++.h. :confused:

libxml++.h belongs to the libxmlxx (libxml C++) library and looks as follows:

Code:
#ifndef __LIBXMLCPP_H
#define __LIBXMLCPP_H

#include <libxml++/exceptions/internal_error.h>
#include <libxml++/exceptions/parse_error.h>
#include <libxml++/parsers/domparser.h>
#include <libxml++/parsers/saxparser.h>
#include <libxml++/nodes/node.h>
#include <libxml++/nodes/commentnode.h>
#include <libxml++/nodes/element.h>
#include <libxml++/nodes/entityreference.h>
#include <libxml++/nodes/textnode.h>
#include <libxml++/attribute.h>
#include <libxml++/document.h>

#endif //__LIBXMLCPP_H

So, that is my situation.

Lastly, as you all can see, my test project only has one source file as follows:
Code:
#include <CoreFoundation/CoreFoundation.h>

#include <libxml++/libxml++.h>

int main (int argc, const char * argv[]) {
    // insert code here...
    CFShow(CFSTR("Hello, World!\n"));
    return 0;
}

How much simpler can it get? :eek:

Cheers!
 
Is "Always search user paths" turned on?

Did you try to include the file with "quotes" instead of <quotes> ?
 
Are you sure you're editing the build configuration that's active? For example you could be editing the Release config but still be on Debug, or vise versa, which would continue to give you the problem.
 
OK, mine is working. Part of my issue was I could not find the proper path. I settled on /usr/lib/ruby/1.8/universal-darwin9.0/ruby.h.

Now, I have a good compile. Now, time to tackle the link errors.

Perhaps I ought best think and position Xcode (besides an editor and project manager and a help and reference system) as a GUI front end to the gcc command. Duh.

Thanks.
 
Hi,

setting up a search path for libs can be done in the same way as setting up a search path for *.h files.

Best regards
Peter
 

Attachments

  • library.png
    library.png
    105.9 KB · Views: 1,732
I've taken a stab at that, and no joy yet. Building a Ruby extension, outside of Xcode, works fine. The output of the extconf.rb is a Makefile, and the output of the Makefile is this:
Code:
todd-burchs-computer:cDistance toddburch$ ruby extconf.rb 
creating Makefile
todd-burchs-computer:cDistance toddburch$ make
gcc -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0 -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0 -I.  -fno-common -arch ppc -arch i386 -Os -pipe -fno-common  -c main.c
cc -arch ppc -arch i386 -pipe -bundle -undefined dynamic_lookup -o cDistance.bundle main.o -L"." -L"/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib" -L. -arch ppc -arch i386    -lruby  -lpthread -ldl -lm  
todd-burchs-computer:cDistance toddburch$

I've tried adding /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib to the Library search Path as you suggested, but the link continues to fail on the external references.

I have a friend that writes Ruby extensions with Xcode, but I think he has changed his Build system to leverage extconf.rb and make. I'm still reading up on how to do this. I've asked for him to create a YouTube video on his setup, but that hasn't happened yet. He said is able to use the debugger and profiler with his setup. That would be great.
 

Attachments

  • Xcode002.png
    Xcode002.png
    74.4 KB · Views: 1,049
  • Xcode003.png
    Xcode003.png
    75.1 KB · Views: 905
  • Xcode001.png
    Xcode001.png
    75.6 KB · Views: 817
@toddburch Maybe you should have a closer look at the documentation of Xcode? A search for "Xcode ruby extension" gives 42 hit at developer.apple.com!
In addition, you can set up a new project create a ruby extension ...
 

Attachments

  • Bild 1.png
    Bild 1.png
    102.4 KB · Views: 997
I also edit the settings of "Header Search Path" to be /opt/local/include
and type
# include <gsl/gsl_xxx.h>
in my program.
But Xcode2 still cannot locate the file.

Can someone save me?

I think I can (if very late). I had the same problem as you, and found your post via google search. Posting this response for the next person who does that.

Make sure you are editing your Target's settings, and not your Project's or executable's settings. I have the same version of XCode as you, and my Target inherits "User Header Search Path" from the Project, but not "Header Search Path". I had to enter it directly into the target.

I am betting they fixed this for newer versions of XCode (which you and I do not have).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.