[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] GSL and XCode
From: |
David Rangel |
Subject: |
Re: [Help-gsl] GSL and XCode |
Date: |
Thu, 25 Feb 2010 13:14:54 +0000 |
Thank you Jonny for the suggestions.
The first suggestion of adding the lstdc++ worked and I could link after
using gcc to compile (compiling with g++ also worked). Thank you!
The second problem is more difficult. Perhaps the -arch ppc is the problem.
I removed ppc from the build options and left only i386. That solved the
problem (I also included the -lstdc++ flag). Here was the log output from
Xcode that along with your helpful comments led to the solution:
___________________________________________
Building target “bessel” of project “bessel” with configuration “Release” —
(1 error, 2 warnings)
cd /Users/rangel/doc/src/bessel
/Developer/usr/bin/gcc-4.0 -o
/Users/rangel/doc/src/bessel/build/bessel.build/Release/bessel.build/Objects-normal/ppc/bessel
-L/Users/rangel/doc/src/bessel/build/Release
-L/Developer/SDKs/MacOSX10.5.sdk/usr/local/lib
-F/Users/rangel/doc/src/bessel/build/Release -filelist
/Users/rangel/doc/src/bessel/build/bessel.build/Release/bessel.build/Objects-normal/ppc/bessel.LinkFileList
-arch ppc -mmacosx-version-min=10.5 -lgsl -lgslcblas -lm -lstdc++ -isysroot
/Developer/SDKs/MacOSX10.5.sdk
ld: warning in /Developer/SDKs/MacOSX10.5.sdk/usr/local/lib/libgsl.dylib,
file is not of required architecture
ld: warning in
/Developer/SDKs/MacOSX10.5.sdk/usr/local/lib/libgslcblas.dylib, file is not
of required architecture
Undefined symbols:
"_gsl_sf_bessel_J0", referenced from:
_main in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
ld: warning in
/Developer/SDKs/MacOSX10.5.sdk/usr/local/lib/libgsl.dylib, file is not of
required architecture
ld: warning in
/Developer/SDKs/MacOSX10.5.sdk/usr/local/lib/libgslcblas.dylib, file is not
of required architecture
"_gsl_sf_bessel_J0", referenced from:
_main in main.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Build failed (1 error, 2 warnings)
___________________________________________
On Thu, Feb 25, 2010 at 12:43 PM, Jonny Taylor <address@hidden>wrote:
> David,
>
> You should be able to solve your first problem by using g++ instead of gcc
> (or add -lstdc++). It's not immediately obvious to me why your code is being
> compiled as c++ code, but that appears to be the case.
>
> As for your second problem I wonder if your project is compiling to a 64
> bit (or universal) binary. Can you post the full Xcode build log showing the
> command line options it's using? If it's working from the command line but
> not from Xcode, the think to do is often to take the Xcode command line from
> the log and start stripping bits out to make it look like your direct
> command line invocation, until it starts working again. That gives you an
> idea of where the problem is coming in...
>
> Hope this helps
> Jonny
>
> On 25 Feb 2010, at 12:34, David Rangel wrote:
>
> > Dear GSL Users:
> >
> > I am attempting to use the GSL library with OSX's IDE XCode. I don't
> know
> > if this is the correct place to place such a question.
> >
> > I am able to use the command line to compile the bessel function example
> > given in the documentation at:
> >
> > http://www.gnu.org/software/gsl/manual/html_node/An-Example-Program.html
> >
> > which is:
> >
> > #include <stdio.h>
> > #include <gsl/gsl_sf_bessel.h>
> >
> > int
> > main (void)
> > {
> > double x = 5.0;
> > double y = gsl_sf_bessel_J0 (x);
> > printf ("J0(%g) = %.18e\n", x, y);
> > return 0;
> > }
> >
> > using the suggested compiling and linking commands:
> >
> > $ gcc -Wall -I/usr/local/include -c example.c
> > $ gcc -L/usr/local/lib example.o -lgsl -lgslcblas -lm
> >
> > It does not link correctly if I use the extension example.cpp which is
> added
> > by default in Xcode and I get the following error if the extension .cpp
> is
> > used instead of .c:
> >
> > Undefined symbols:
> > "___gxx_personality_v0", referenced from:
> > ___gxx_personality_v0$non_lazy_ptr in example.o
> > ld: symbol(s) not found
> > collect2: ld returned 1 exit status
> >
> >
> > If I try to compile using XCode with the header search path set to
> > /usr/local/include and library search path to /usr/local/lib where the
> gsl
> > libraries are installed, I receive the following error during the linking
> > stage:
> >
> > "_gsl_sf_bessel_J0", referenced from:
> > _main in main.o
> > ld: symbol(s) not found
> > collect2: ld returned 1 exit status
> >
> > I also get the following warnings:
> >
> > ld: warning in /Developer/SDKs/MacOSX10.5.sdk/usr/local/lib/libgsl.dylib,
> > file is not of required architecture
> > ld: warning in
> > /Developer/SDKs/MacOSX10.5.sdk/usr/local/lib/libgslcblas.dylib, file is
> not
> > of required architecture
> >
> > I have tried switching the compiler from default to C ANSI but this does
> not
> > solve the problem. I have tried renaming the file with the .c extension.
> > None of these helps eliminate the linking problem I searched on the web
> for
> > a solution to this problem, but cannot find a definitive answer.
> >
> > I was wondering if this is the correct place to pose this question, and
> if
> > so, if anyone has experience using GSL with XCode and what is required to
> > make it work.
> >
> > Thank you for your time and input.
> > _______________________________________________
> > Help-gsl mailing list
> > address@hidden
> > http://lists.gnu.org/mailman/listinfo/help-gsl
>
>