Using Apple Xcode 3.0 as IDE

I’m trying to move my development from Emacs to Xcode, but I have trouble when the compiler want to link with the ROOT libraries.

What I do:

Create a new project: “Carbon C++ Application”

In the info section for the project I :

  • change Arch. to i386 (del. PPC)
  • HEADER_SEARCH_PATHS = /Applications/root/include
  • LIBRARY_SEARCH_PATHS = /Applications/root/lib

Trying to compile gives me the following error:

Line Location Tool:0: collect2: ld returned 1 exit status
Line Location Tool:0: symbol(s) not found
Line Location Tool:0: __static_initialization_and_destruction_0(int, int)in test.o
Line Location Tool:0: “TVersionCheck::TVersionCheck(int)”, referenced from:

In this case I tried using this code: root.cern.ch/root/html/examples/ … emo.C.html

Can anybody help me along :confused:

Hi,

I am not in front of my mac, so here are just a few guesses about what could be wrong but without any warranty.

Why a Carbon application ? I would simply take a C++ project (if it exists) or an empty project. Or are you really developing something with Carbon ?

Try to add the libraries directly in the project (but keep your settings as they are).
Right click on your project and select “Add…” → “Add an existing framework”. There you choose in /Applications/root/lib the libraries you need.

Let me know if it helps or not. Good luck

Barth

Hi thanks for the response!

I don’t think I had a clean option in Xcode 3.0 without having to set up all the compiler and linker options.

Now I upgraded to 3.1 and choose “C++ Tool” which is a basic command-line template.

[quote=“Barth”]
Try to add the libraries directly in the project (but keep your settings as they are).
Right click on your project and select “Add…” → “Add an existing framework”. There you choose in /Applications/root/lib the libraries you need.

Let me know if it helps or not. Good luck

Barth[/quote]
It did! I can compile now, but how do I figure out which libs to include, because it complains at run-time if you link with something that isn’t used:

ld: Library not loaded: /Users/bellenot/ROOT/osx104_ia32_gcc401/root/lib/libCore.dylib Referenced from: /Users/mdj/Desktop/slet/build/Debug/slet Reason: image not found Trace/BPT trap

— Even more weird I’m not bellenot :S

[quote=“mdj”]Hi thanks for the response!

Now I upgraded to 3.1 and choose “C++ Tool” which is a basic command-line template.
[/quote]
Good, this is better.

[quote=“mdj”]

[quote=“Barth”]
Let me know if it helps or not. Good luck
Barth[/quote]
It did! I can compile now, but how do I figure out which libs to include, because it complains at run-time if you link with something that isn’t used:

ld: Library not loaded: /Users/bellenot/ROOT/osx104_ia32_gcc401/root/lib/libCore.dylib Referenced from: /Users/mdj/Desktop/slet/build/Debug/slet Reason: image not found Trace/BPT trap

— Even more weird I’m not bellenot :S[/quote]

Well, I don’t think it is complaining about the libraries you don’t use but more likely because it can’t load the libraries.
It seems to be looking for libCore in the wrong place. As if you had an hard-coded reference coming directly from Bertrand Bellenot’s computer. Are you sure you are launching the correct executable ? Betrand do you have any idea how this is possible ?

I will think more about it and keep you informed if I think about something.

Barth

was there any further progress on this issue. i am getting the same bellenot problem and all of my attempts to find a solution have failed.
thanks,
james

Hi,

I never used Xcode as IDE, but usually the “bellenot” problem comes because DYLD_LIBRARY_PATH is missing, or not pointing to $ROOTSYS/lib…

Cheers, Bertrand.

Hi,

here is a recipe that works for me using Xcode 3.2 (and I guess also will work for 3.1).
[ul]

  • Create Command Line Tool (Type C++ stdc++)
  • Edit main.cpp to contain the ROOT program you like (for demo I added the test/hworld.cxx code in this file)
  • Open Edit Active Target from the Project menu and make the following changes in the Build pane:
  • Other Linker Flags: -L/Users/rdm/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lz -pthread -lm -ldl
  • Runpath Search Paths: /Users/rdm/root/lib
  • Header Search Paths: /Users/rdm/root/include
  • Other C++ Flags: -D_REENTRANT -pthread
  • Click on Build in the project window or CMD-B
  • Select Run from the Run menu
    [/ul]

The values I filled in in the Build pane of the Active target come from running:

root-config --cflags
root-config --libs

Hope this helps.

Cheers, Fons.

Hallo!
i also want to use root with xcode. i did everyting that is written above. but i get the errors e.a.
"error: TF1.h: No such file or directory"
so he does not find the headder files.
what could be the problem?

my runsearch paths: /Users/iRobert148/Applications/root/lib
header search path: /Users/iRobert148/Applications/root/include

everyting else is the same and he still doesnt find the headers. :angry:

When looking in the Xcode log pane, hoe does the compilevstatement look like? Is there any -I statement with the ROOT include path. Please double check your settings.

Cheers, Fons.

hi rdm,
ich checked everything twice. i use root 5.26 and xcode 3.2.2.

where can i find the Xcode log pane?

there u can see my settings, i hope it helps you for helping me (-;
img227.imageshack.us/gal.php?g=b … 00629u.png

To see the “Build Results” pane, click first in the upper left “project” icon. Then the “Build Results” pane is the most right one in the right pane. I’ve added the example ROOT based Xcode project that works for me.

Cheers, Fons.
ROOT-based-app.xcode.tar.gz (311 KB)

hi, i tried your demoporject
buildresult:

Build ROOT-based-app of project ROOT-based-app with configuration Debug

CompileC build/ROOT-based-app.build/Debug/ROOT-based-app.build/Objects-normal/x86_64/main.o main.cpp normal x86_64 c++ com.apple.compilers.gcc.4_2
cd /Users/iRobert148/Downloads/ROOT-based-app
setenv LANG en_US.US-ASCII
/Applications/Xcode/usr/bin/gcc-4.2 -x c++ -arch x86_64 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -isysroot /Applications/Xcode/SDKs/MacOSX10.6.sdk -mfix-and-continue -fvisibility-inlines-hidden -mmacosx-version-min=10.6 -gdwarf-2 -iquote /Users/iRobert148/Downloads/ROOT-based-app/build/ROOT-based-app.build/Debug/ROOT-based-app.build/ROOT-based-app-generated-files.hmap -I/Users/iRobert148/Downloads/ROOT-based-app/build/ROOT-based-app.build/Debug/ROOT-based-app.build/ROOT-based-app-own-target-headers.hmap -I/Users/iRobert148/Downloads/ROOT-based-app/build/ROOT-based-app.build/Debug/ROOT-based-app.build/ROOT-based-app-all-target-headers.hmap -iquote /Users/iRobert148/Downloads/ROOT-based-app/build/ROOT-based-app.build/Debug/ROOT-based-app.build/ROOT-based-app-project-headers.hmap -F/Users/iRobert148/Downloads/ROOT-based-app/build/Debug -I/Users/iRobert148/Downloads/ROOT-based-app/build/Debug/include -I/Users/rdm/root/include -I/Users/iRobert148/Downloads/ROOT-based-app/build/ROOT-based-app.build/Debug/ROOT-based-app.build/DerivedSources/x86_64 -I/Users/iRobert148/Downloads/ROOT-based-app/build/ROOT-based-app.build/Debug/ROOT-based-app.build/DerivedSources -D_REENTRANT -pthread -c /Users/iRobert148/Downloads/ROOT-based-app/main.cpp -o /Users/iRobert148/Downloads/ROOT-based-app/build/ROOT-based-app.build/Debug/ROOT-based-app.build/Objects-normal/x86_64/main.o

/Users/iRobert148/Downloads/ROOT-based-app/main.cpp:8:26: error: TApplication.h: No such file or directory
/Users/iRobert148/Downloads/ROOT-based-app/main.cpp:9:21: error: TCanvas.h: No such file or directory
/Users/iRobert148/Downloads/ROOT-based-app/main.cpp:10:19: error: TLine.h: No such file or directory
/Users/iRobert148/Downloads/ROOT-based-app/main.cpp:11:24: error: TPaveLabel.h: No such file or directory
/Users/iRobert148/Downloads/ROOT-based-app/main.cpp: In function ‘int main(int, char**)’:
/Users/iRobert148/Downloads/ROOT-based-app/main.cpp:15: error: ‘TApplication’ was not declared in this scope
/Users/iRobert148/Downloads/ROOT-based-app/main.cpp:15: error: expected ;' before 'theApp' /Users/iRobert148/Downloads/ROOT-based-app/main.cpp:17: error: 'TCanvas' was not declared in this scope /Users/iRobert148/Downloads/ROOT-based-app/main.cpp:17: error: 'c' was not declared in this scope /Users/iRobert148/Downloads/ROOT-based-app/main.cpp:17: error: expected type-specifier before 'TCanvas' /Users/iRobert148/Downloads/ROOT-based-app/main.cpp:17: error: expected;’ before ‘TCanvas’
/Users/iRobert148/Downloads/ROOT-based-app/main.cpp:18: error: ‘theApp’ was not declared in this scope
/Users/iRobert148/Downloads/ROOT-based-app/main.cpp:20: error: ‘TPaveLabel’ was not declared in this scope
/Users/iRobert148/Downloads/ROOT-based-app/main.cpp:20: error: ‘hello’ was not declared in this scope
/Users/iRobert148/Downloads/ROOT-based-app/main.cpp:20: error: expected type-specifier before ‘TPaveLabel’
/Users/iRobert148/Downloads/ROOT-based-app/main.cpp:20: error: expected ;' before 'TPaveLabel' /Users/iRobert148/Downloads/ROOT-based-app/main.cpp:22: error: 'quit' was not declared in this scope /Users/iRobert148/Downloads/ROOT-based-app/main.cpp:22: error: expected type-specifier before 'TPaveLabel' /Users/iRobert148/Downloads/ROOT-based-app/main.cpp:22: error: expected;’ before ‘TPaveLabel’

Please go in the “Project” -> “Edit Active Target”. Go to the “Build” pane, and type in the “Search” area: rdm

Change all the strings with rdm to the paths valid on your system.

Cheers, Fons.

i cant find the rdm content in your target settings,
when i build a project with my settings, i get that result:

Build test of project test with configuration Debug

CompileC build/test.build/Debug/test.build/Objects-normal/x86_64/main.o main.cpp normal x86_64 c++ com.apple.compilers.gcc.4_2
cd /Users/iRobert148/Desktop/test
setenv LANG en_US.US-ASCII
/Applications/Xcode/usr/bin/gcc-4.2 -x c++ -arch x86_64 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -isysroot /Applications/Xcode/SDKs/MacOSX10.6.sdk -mfix-and-continue -fvisibility-inlines-hidden -mmacosx-version-min=10.6 -gdwarf-2 -iquote /Users/iRobert148/Desktop/test/build/test.build/Debug/test.build/test-generated-files.hmap -I/Users/iRobert148/Desktop/test/build/test.build/Debug/test.build/test-own-target-headers.hmap -I/Users/iRobert148/Desktop/test/build/test.build/Debug/test.build/test-all-target-headers.hmap -iquote /Users/iRobert148/Desktop/test/build/test.build/Debug/test.build/test-project-headers.hmap -F/Users/iRobert148/Desktop/test/build/Debug -I/Users/iRobert148/Desktop/test/build/Debug/include -I/Users/iRobert148/Desktop/test/build/test.build/Debug/test.build/DerivedSources/x86_64 -I/Users/iRobert148/Desktop/test/build/test.build/Debug/test.build/DerivedSources -c /Users/iRobert148/Desktop/test/main.cpp -o /Users/iRobert148/Desktop/test/build/test.build/Debug/test.build/Objects-normal/x86_64/main.o

/Users/iRobert148/Desktop/test/main.cpp:8:26: error: TApplication.h: No such file or directory
/Users/iRobert148/Desktop/test/main.cpp:9:21: error: TCanvas.h: No such file or directory
/Users/iRobert148/Desktop/test/main.cpp:10:19: error: TLine.h: No such file or directory
/Users/iRobert148/Desktop/test/main.cpp:11:24: error: TPaveLabel.h: No such file or directory
/Users/iRobert148/Desktop/test/main.cpp: In function ‘int main(int, char**)’:
/Users/iRobert148/Desktop/test/main.cpp:15: error: ‘TApplication’ was not declared in this scope
/Users/iRobert148/Desktop/test/main.cpp:15: error: expected ;' before 'theApp' /Users/iRobert148/Desktop/test/main.cpp:17: error: 'TCanvas' was not declared in this scope /Users/iRobert148/Desktop/test/main.cpp:17: error: 'c' was not declared in this scope /Users/iRobert148/Desktop/test/main.cpp:17: error: expected type-specifier before 'TCanvas' /Users/iRobert148/Desktop/test/main.cpp:17: error: expected;’ before ‘TCanvas’
/Users/iRobert148/Desktop/test/main.cpp:18: error: ‘theApp’ was not declared in this scope
/Users/iRobert148/Desktop/test/main.cpp:20: error: ‘TPaveLabel’ was not declared in this scope
/Users/iRobert148/Desktop/test/main.cpp:20: error: ‘hello’ was not declared in this scope
/Users/iRobert148/Desktop/test/main.cpp:20: error: expected type-specifier before ‘TPaveLabel’
/Users/iRobert148/Desktop/test/main.cpp:20: error: expected ;' before 'TPaveLabel' /Users/iRobert148/Desktop/test/main.cpp:22: error: 'quit' was not declared in this scope /Users/iRobert148/Desktop/test/main.cpp:22: error: expected type-specifier before 'TPaveLabel' /Users/iRobert148/Desktop/test/main.cpp:22: error: expected;’ before ‘TPaveLabel’

when i open your project, c++ cflags, linker flags… are empty. maybe i check it at the wrong place?
project/edit active targer i correct, isnt it?

I don’t see these:

my runsearch paths: /Users/iRobert148/Applications/root/lib
header search path: /Users/iRobert148/Applications/root/include

i.e.

-I/Users/iRobert148/Applications/root/include

in the compile statement. Please fix that first.

Cheers, Fons.

but i add it, maybe check the pictures if its correct,
again de results:

Build test of project test with configuration Debug

CompileC build/test.build/Debug/test.build/Objects-normal/x86_64/main.o main.cpp normal x86_64 c++ com.apple.compilers.gcc.4_2
cd /Users/iRobert148/Desktop/test
setenv LANG en_US.US-ASCII
/Applications/Xcode/usr/bin/gcc-4.2 -x c++ -arch x86_64 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -isysroot /Applications/Xcode/SDKs/MacOSX10.6.sdk -mfix-and-continue -fvisibility-inlines-hidden -mmacosx-version-min=10.6 -gdwarf-2 -iquote /Users/iRobert148/Desktop/test/build/test.build/Debug/test.build/test-generated-files.hmap -I/Users/iRobert148/Desktop/test/build/test.build/Debug/test.build/test-own-target-headers.hmap -I/Users/iRobert148/Desktop/test/build/test.build/Debug/test.build/test-all-target-headers.hmap -iquote /Users/iRobert148/Desktop/test/build/test.build/Debug/test.build/test-project-headers.hmap -F/Users/iRobert148/Desktop/test/build/Debug -I/Users/iRobert148/Desktop/test/build/Debug/include -I/Users/iRobert148/Desktop/test/build/test.build/Debug/test.build/DerivedSources/x86_64 -I/Users/iRobert148/Desktop/test/build/test.build/Debug/test.build/DerivedSources -c /Users/iRobert148/Desktop/test/main.cpp -o /Users/iRobert148/Desktop/test/build/test.build/Debug/test.build/Objects-normal/x86_64/main.o

/Users/iRobert148/Desktop/test/main.cpp:8:26: error: TApplication.h: No such file or directory
/Users/iRobert148/Desktop/test/main.cpp:9:21: error: TCanvas.h: No such file or directory
/Users/iRobert148/Desktop/test/main.cpp:10:19: error: TLine.h: No such file or directory
/Users/iRobert148/Desktop/test/main.cpp:11:24: error: TPaveLabel.h: No such file or directory
/Users/iRobert148/Desktop/test/main.cpp: In function ‘int main(int, char**)’:
/Users/iRobert148/Desktop/test/main.cpp:15: error: ‘TApplication’ was not declared in this scope
/Users/iRobert148/Desktop/test/main.cpp:15: error: expected ;' before 'theApp' /Users/iRobert148/Desktop/test/main.cpp:17: error: 'TCanvas' was not declared in this scope /Users/iRobert148/Desktop/test/main.cpp:17: error: 'c' was not declared in this scope /Users/iRobert148/Desktop/test/main.cpp:17: error: expected type-specifier before 'TCanvas' /Users/iRobert148/Desktop/test/main.cpp:17: error: expected;’ before ‘TCanvas’
/Users/iRobert148/Desktop/test/main.cpp:18: error: ‘theApp’ was not declared in this scope
/Users/iRobert148/Desktop/test/main.cpp:20: error: ‘TPaveLabel’ was not declared in this scope
/Users/iRobert148/Desktop/test/main.cpp:20: error: ‘hello’ was not declared in this scope
/Users/iRobert148/Desktop/test/main.cpp:20: error: expected type-specifier before ‘TPaveLabel’
/Users/iRobert148/Desktop/test/main.cpp:20: error: expected ;' before 'TPaveLabel' /Users/iRobert148/Desktop/test/main.cpp:22: error: 'quit' was not declared in this scope /Users/iRobert148/Desktop/test/main.cpp:22: error: expected type-specifier before 'TPaveLabel' /Users/iRobert148/Desktop/test/main.cpp:22: error: expected;’ before ‘TPaveLabel’




This should be ok, there don’t happen to be typo’s in these strings. The directories exist? No other ideas. Also add to “Other Linker Flags”

-L/Users/rdm/root/lib -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lz -pthread -lm -ldl

and change the -L path, of course.

Again with 3.2.3 it all works fine for me.

Cheers, Fons.

still doesnt works )-;
but if i tage your project and chance alle …/rdm/… against my path, it works FINE!
strange, i really would like to know what is missing in my configs, i compared them without and found no difference. but ok, finaly i can use root with xcode (-;
thx alot

Make diffs of the files in the Xcode project to see the difference. Good that it works now.

Cheers, Fons.

In case someone else is stuck with this:
Judging by the error/warning messages I had the same or at least a very similar problem with the
Xcode project I created.
Fons’ project worked for me and just from visual inspection in the project/target settings everything
seemed to be identical (after replacing the /rdm/ part of the paths).
I even used the same main.cpp.

A diff of the package content of the xcodeproj-file showed some newlines (\n) to be the problem,
that are all but invisible in the Xcode GUI.
E.g. “/include[color=#FF0000]\n[/color]”

Turns out they were left over after copying and pasting the output of root-config into the Xcode GUI.

After removing them everything else worked “as advertised”.

Cheers, Robert