How to build programs with gdc installed in /opt/gdc (using SCons)?

Ed eturpin at live.com
Thu Aug 23 17:32:57 PDT 2012


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:

DefaultEnvironment(DC='/opt/gdc/bin/gdmd')
Program('helloworld',
         'main.d',
         LIBPATH='/opt/gdc/lib64',
         LIBS='gphobos2')

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 
`_STI_monitor_staticctor':
/home/ed/code/gdc/gdc/dev/gcc-4.6.2/objdir/x86_64-unknown-linux-gnu/libphobos/../../../libphobos/rt/monitor_.d:191: 
undefined reference to `pthread_mutexattr_init'
/home/ed/code/gdc/gdc/dev/gcc-4.6.2/objdir/x86_64-unknown-linux-gnu/libphobos/../../../libphobos/rt/monitor_.d:192: 
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?


More information about the D.gnu mailing list