www.digitalmars.com         C & C++   DMDScript  

D.gnu - How to build programs with gdc installed in /opt/gdc (using SCons)?

reply "Ed" <eturpin live.com> writes:
I come from a Java background, using mostly just IDEs to handle 
builds, so I'm very confused about how all this linking is done.

I installed GDC from source into /opt/gdc, and I'm trying to 
build a simple program using SCons.

After a lot of experimenting, I came up with this SConstruct file:


When I run scons, these commands are executed:

/opt/gdc/bin/gdmd -I. -c -ofmain.o main.d
Use of uninitialized value $ENV{"HOME"} in concatenation (.) or 
string at /opt/gdc/bin/gdmd line 186.
gcc -o helloworld main.o -L/opt/gdc/lib64 -lgphobos2

then, I get a bunch of undefined reference errors like this:

/opt/gdc/lib64/libgphobos2.a(monitor_.o): In function 
undefined reference to `pthread_mutexattr_init'
undefined reference to `pthread_mutexattr_settype'

I also don't know why it's saying these files are in /home/ed/... 
That's where I compiled them from before installing to /opt, but 
they are not there anymore.

The /opt/gdc directory structure is:

$ ls /opt/gdc
bin  include  lib  lib32  lib64  libexec  share

So, what's going on here, and how do I go about building the 
helloworld program?
Aug 23 2012
parent "Ed" <eturpin live.com> writes:
Nevermind, I think I figured it out. Looks like libgphobos2 
depends on libm, libpthread, and librt. So, changing the 
SConstruct file to:


Solves the problem. Though, if there's a better way to do things, 
feel free to let me know.
Aug 23 2012