www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - gdc compiler/linker error

reply Jonathan Crapuchettes <jcrapuchettes gmail.com> writes:
I am getting a linker error when I try to compile my code as follows:

jonathan blackbeard:~/workspace/ccb/matrix$ gdmd test.d Matrix.d Vector.d
Util.d 
../MySQLConnection.d -unittest -I../.. -L/usr/lib/atlas/libptcblas.a 
-L/usr/lib/atlas/liblapack.a -L/usr/lib/atlas/libatlas.a 
-L/usr/lib/atlas/libcblas.a -L/usr/lib/atlas/libblas.a 
-L/usr/lib/libmysqlclient.so -vdmd
/usr/bin/gdc -funittest -I ../.. -c test.d -o test.o
/usr/bin/gdc -funittest -I ../.. -c Matrix.d -o Matrix.o
/usr/bin/gdc -funittest -I ../.. -c Vector.d -o Vector.o
/usr/bin/gdc -funittest -I ../.. -c Util.d -o Util.o
/usr/bin/gdc -funittest -I ../.. -c ../MySQLConnection.d -o MySQLConnection.o
/usr/bin/gdc -funittest -I ../.. test.o Matrix.o Vector.o Util.o 
MySQLConnection.o -Wl,/usr/lib/atlas/libptcblas.a
-Wl,/usr/lib/atlas/liblapack.a 
-Wl,/usr/lib/atlas/libatlas.a -Wl,/usr/lib/atlas/libcblas.a 
-Wl,/usr/lib/atlas/libblas.a -Wl,/usr/lib/libmysqlclient.so -o test
Util.o: In function `_D3ccb6matrix4Util11__unittest0FZv':
Util.d:(.text+0x2ec4): undefined reference to 
`_D3ccb15MySQLConnection15mysqlConnection7__ClassZ'
Util.d:(.text+0x2f22): undefined reference to 
`_D3ccb15MySQLConnection15mysqlConnection5_ctorMFAaAaAaAaZC3ccb15MySQLConnection15mysqlConnection'
collect2: ld returned 1 exit status

I am trying to use gdc for its 64-bit compilation, but this is a problem. I 
checked the compiled code inside MySQLConnection.o with objdump and found that 
_D3ccb15MySQLConnection15MysqlConnection7__ClassZ exists. The only different 
between this label and the one that is causing the error is the m in the last 
term. The name of the class is MysqlConnection.

I am using gdc (GCC) 4.1.3 20070831 (prerelease gdc 0.25, using dmd 1.021) 
(Ubuntu 0.25-4.1.2-16ubuntu1).

What can I do to get this is compile and link?

Thank you taking to read this,
JC
Apr 17 2008
next sibling parent reply Jason House <jason.james.house gmail.com> writes:
Jonathan Crapuchettes wrote:

 I am getting a linker error when I try to compile my code as follows:
 
 jonathan blackbeard:~/workspace/ccb/matrix$ gdmd test.d Matrix.d Vector.d
 Util.d ../MySQLConnection.d -unittest -I../..
 -L/usr/lib/atlas/libptcblas.a -L/usr/lib/atlas/liblapack.a
 -L/usr/lib/atlas/libatlas.a -L/usr/lib/atlas/libcblas.a
 -L/usr/lib/atlas/libblas.a -L/usr/lib/libmysqlclient.so -vdmd
 /usr/bin/gdc -funittest -I ../.. -c test.d -o test.o
 /usr/bin/gdc -funittest -I ../.. -c Matrix.d -o Matrix.o
 /usr/bin/gdc -funittest -I ../.. -c Vector.d -o Vector.o
 /usr/bin/gdc -funittest -I ../.. -c Util.d -o Util.o
 /usr/bin/gdc -funittest -I ../.. -c ../MySQLConnection.d -o
 MySQLConnection.o /usr/bin/gdc -funittest -I ../.. test.o Matrix.o
 Vector.o Util.o MySQLConnection.o -Wl,/usr/lib/atlas/libptcblas.a
 -Wl,/usr/lib/atlas/liblapack.a -Wl,/usr/lib/atlas/libatlas.a
 -Wl,/usr/lib/atlas/libcblas.a -Wl,/usr/lib/atlas/libblas.a
 -Wl,/usr/lib/libmysqlclient.so -o test Util.o: In function
 `_D3ccb6matrix4Util11__unittest0FZv': Util.d:(.text+0x2ec4): undefined
 reference to `_D3ccb15MySQLConnection15mysqlConnection7__ClassZ'
 Util.d:(.text+0x2f22): undefined reference to
`_D3ccb15MySQLConnection15mysqlConnection5_ctorMFAaAaAaAaZC3ccb15MySQLConnection15mysqlConnection'
 collect2: ld returned 1 exit status
 
 I am trying to use gdc for its 64-bit compilation, but this is a problem.
 I checked the compiled code inside MySQLConnection.o with objdump and
 found that _D3ccb15MySQLConnection15MysqlConnection7__ClassZ exists. The
 only different between this label and the one that is causing the error is
 the m in the last term. The name of the class is MysqlConnection.
 
 I am using gdc (GCC) 4.1.3 20070831 (prerelease gdc 0.25, using dmd 1.021)
 (Ubuntu 0.25-4.1.2-16ubuntu1).
 
 What can I do to get this is compile and link?
 
 Thank you taking to read this,
 JC
If you pick up a d demangler and run it on the output, it'll make it easier for others to interpret. It may even have the unexpected side effect of making the error obvious.
Apr 17 2008
parent Tower Ty <towerty msn.com.au> writes:
Jason House Wrote:

 Jonathan Crapuchettes wrote:
 
 I am getting a linker error when I try to compile my code as follows:
 
 jonathan blackbeard:~/workspace/ccb/matrix$ gdmd test.d Matrix.d Vector.d
 Util.d ../MySQLConnection.d -unittest -I../..
 -L/usr/lib/atlas/libptcblas.a -L/usr/lib/atlas/liblapack.a
 -L/usr/lib/atlas/libatlas.a -L/usr/lib/atlas/libcblas.a
 -L/usr/lib/atlas/libblas.a -L/usr/lib/libmysqlclient.so -vdmd
 /usr/bin/gdc -funittest -I ../.. -c test.d -o test.o
 /usr/bin/gdc -funittest -I ../.. -c Matrix.d -o Matrix.o
 /usr/bin/gdc -funittest -I ../.. -c Vector.d -o Vector.o
 /usr/bin/gdc -funittest -I ../.. -c Util.d -o Util.o
 /usr/bin/gdc -funittest -I ../.. -c ../MySQLConnection.d -o
 MySQLConnection.o /usr/bin/gdc -funittest -I ../.. test.o Matrix.o
 Vector.o Util.o MySQLConnection.o -Wl,/usr/lib/atlas/libptcblas.a
 -Wl,/usr/lib/atlas/liblapack.a -Wl,/usr/lib/atlas/libatlas.a
 -Wl,/usr/lib/atlas/libcblas.a -Wl,/usr/lib/atlas/libblas.a
 -Wl,/usr/lib/libmysqlclient.so -o test Util.o: In function
 `_D3ccb6matrix4Util11__unittest0FZv': Util.d:(.text+0x2ec4): undefined
 reference to `_D3ccb15MySQLConnection15mysqlConnection7__ClassZ'
 Util.d:(.text+0x2f22): undefined reference to
`_D3ccb15MySQLConnection15mysqlConnection5_ctorMFAaAaAaAaZC3ccb15MySQLConnection15mysqlConnection'
 collect2: ld returned 1 exit status
 
 I am trying to use gdc for its 64-bit compilation, but this is a problem.
 I checked the compiled code inside MySQLConnection.o with objdump and
 found that _D3ccb15MySQLConnection15MysqlConnection7__ClassZ exists. The
 only different between this label and the one that is causing the error is
 the m in the last term. The name of the class is MysqlConnection.
 
 I am using gdc (GCC) 4.1.3 20070831 (prerelease gdc 0.25, using dmd 1.021)
 (Ubuntu 0.25-4.1.2-16ubuntu1).
 
 What can I do to get this is compile and link?
 
 Thank you taking to read this,
 JC
If you pick up a d demangler and run it on the output, it'll make it easier for others to interpret. It may even have the unexpected side effect of making the error obvious.
If hes using tango then there isn't one I don't think Phobos has one for use in Linux This question is in the ".D" forum also and I passed on it in case I lower your chances of an answer, however I'd suggest that somewhere in reference to `_D3ccb15MySQLConnection15mysqlConnection7__ClassZ' and `_D3ccb15MySQLConnection15mysqlConnection5_ctorMFAaAaAaAaZC3ccb15MySQLConnection15mysqlConnection' is a clue . I would be looking for "MySQLConnection.mysqlConnection" typed somewhere instead of "MySQLConnection.MysqlConnection" You are right about the m I think Anyway some much smarter people on here will hopefuly read the output and be able to interpret it clearly for you
Apr 17 2008
prev sibling next sibling parent reply Markus Dittrich <markusle gmail.com> writes:
Jonathan Crapuchettes Wrote:

 I am getting a linker error when I try to compile my code as follows:
 /usr/bin/gdc -funittest -I ../.. test.o Matrix.o Vector.o Util.o 
 MySQLConnection.o -Wl,/usr/lib/atlas/libptcblas.a
-Wl,/usr/lib/atlas/liblapack.a 
 -Wl,/usr/lib/atlas/libatlas.a -Wl,/usr/lib/atlas/libcblas.a 
 -Wl,/usr/lib/atlas/libblas.a -Wl,/usr/lib/libmysqlclient.so -o test
 Util.o: In function `_D3ccb6matrix4Util11__unittest0FZv':
 Util.d:(.text+0x2ec4): undefined reference to 
 `_D3ccb15MySQLConnection15mysqlConnection7__ClassZ'
 Util.d:(.text+0x2f22): undefined reference to 
Have you tried putting MySQLConnection.o before Util.o when linking? cheers, Markus
Apr 17 2008
parent Jonathan Crapuchettes <jcrapuchettes gmail.com> writes:
Yes, but sadly I got the same result.
JC

Markus Dittrich wrote:
 Jonathan Crapuchettes Wrote:
 
 I am getting a linker error when I try to compile my code as follows:
 /usr/bin/gdc -funittest -I ../.. test.o Matrix.o Vector.o Util.o 
 MySQLConnection.o -Wl,/usr/lib/atlas/libptcblas.a
-Wl,/usr/lib/atlas/liblapack.a 
 -Wl,/usr/lib/atlas/libatlas.a -Wl,/usr/lib/atlas/libcblas.a 
 -Wl,/usr/lib/atlas/libblas.a -Wl,/usr/lib/libmysqlclient.so -o test
 Util.o: In function `_D3ccb6matrix4Util11__unittest0FZv':
 Util.d:(.text+0x2ec4): undefined reference to 
 `_D3ccb15MySQLConnection15mysqlConnection7__ClassZ'
 Util.d:(.text+0x2f22): undefined reference to 
Have you tried putting MySQLConnection.o before Util.o when linking? cheers, Markus
Apr 18 2008
prev sibling parent reply "Neil Vice" <psgdg swiftdsl.com.au> writes:
"Jonathan Crapuchettes" <jcrapuchettes gmail.com> wrote in message 
news:fu8iu2$98s$1 digitalmars.com...
I am getting a linker error when I try to compile my code as follows:

 jonathan blackbeard:~/workspace/ccb/matrix$ gdmd test.d Matrix.d Vector.d 
 Util.d 
 ../MySQLConnection.d -unittest -I../.. -L/usr/lib/atlas/libptcblas.a
-L/usr/lib/atlas/liblapack.a 
  -L/usr/lib/atlas/libatlas.a -L/usr/lib/atlas/libcblas.a
-L/usr/lib/atlas/libblas.a 
  -L/usr/lib/libmysqlclient.so -vdmd
 /usr/bin/gdc -funittest -I ../.. -c test.d -o test.o
 /usr/bin/gdc -funittest -I ../.. -c Matrix.d -o Matrix.o
 /usr/bin/gdc -funittest -I ../.. -c Vector.d -o Vector.o
 /usr/bin/gdc -funittest -I ../.. -c Util.d -o Util.o
 /usr/bin/gdc -funittest -I ../.. -c ../MySQLConnection.d -o 
 MySQLConnection.o
 /usr/bin/gdc -funittest -I ../.. test.o Matrix.o Vector.o Util.o 
 MySQLConnection.o -Wl,/usr/lib/atlas/libptcblas.a
-Wl,/usr/lib/atlas/liblapack.a 
  -Wl,/usr/lib/atlas/libatlas.a -Wl,/usr/lib/atlas/libcblas.a
-Wl,/usr/lib/atlas/libblas.a 
  -Wl,/usr/lib/libmysqlclient.so -o test
 Util.o: In function `_D3ccb6matrix4Util11__unittest0FZv':
 Util.d:(.text+0x2ec4): undefined reference to 
 `_D3ccb15MySQLConnection15mysqlConnection7__ClassZ'
 Util.d:(.text+0x2f22): undefined reference to 
 `_D3ccb15MySQLConnection15mysqlConnection5_ctorMFAaAaAaAaZC3ccb15MySQLConnection15mysqlConnection'
 collect2: ld returned 1 exit status

 I am trying to use gdc for its 64-bit compilation, but this is a problem. 
 I checked the compiled code inside MySQLConnection.o with objdump and 
 found that _D3ccb15MySQLConnection15MysqlConnection7__ClassZ exists. The 
 only different between this label and the one that is causing the error is 
 the m in the last term. The name of the class is MysqlConnection.

 I am using gdc (GCC) 4.1.3 20070831 (prerelease gdc 0.25, using dmd 1.021) 
 (Ubuntu 0.25-4.1.2-16ubuntu1).

 What can I do to get this is compile and link?

 Thank you taking to read this,
 JC
I don't see why a single compiler would generate two different mangled names for the same identifier. As such, I wonder where the two object files involved were obtained from? Could they have been built with different compiler versions somehow? Did you obtain one of them as a binary? If so, perhaps the case in the associated extern declaration is incorrect... I also know that DMD acts differently if you compile a series of files in the one command or compile each seperately and the link. Don't think this would apply to GDC but another thought... Good luck
Apr 18 2008
parent Jonathan Crapuchettes <jcrapuchettes gmail.com> writes:
Thank you for your thoughts, but as you can see from the gdmd output, all
object 
files were created at the same time by the same compiler. I am starting to 
wonder if it isn't a bug in gdc.
Thanks again,
JC

Neil Vice wrote:
 "Jonathan Crapuchettes" <jcrapuchettes gmail.com> wrote in message 
 news:fu8iu2$98s$1 digitalmars.com...
 I am getting a linker error when I try to compile my code as follows:

 jonathan blackbeard:~/workspace/ccb/matrix$ gdmd test.d Matrix.d Vector.d 
 Util.d 
 ../MySQLConnection.d -unittest -I../.. -L/usr/lib/atlas/libptcblas.a
-L/usr/lib/atlas/liblapack.a 
  -L/usr/lib/atlas/libatlas.a -L/usr/lib/atlas/libcblas.a
-L/usr/lib/atlas/libblas.a 
  -L/usr/lib/libmysqlclient.so -vdmd
 /usr/bin/gdc -funittest -I ../.. -c test.d -o test.o
 /usr/bin/gdc -funittest -I ../.. -c Matrix.d -o Matrix.o
 /usr/bin/gdc -funittest -I ../.. -c Vector.d -o Vector.o
 /usr/bin/gdc -funittest -I ../.. -c Util.d -o Util.o
 /usr/bin/gdc -funittest -I ../.. -c ../MySQLConnection.d -o 
 MySQLConnection.o
 /usr/bin/gdc -funittest -I ../.. test.o Matrix.o Vector.o Util.o 
 MySQLConnection.o -Wl,/usr/lib/atlas/libptcblas.a
-Wl,/usr/lib/atlas/liblapack.a 
  -Wl,/usr/lib/atlas/libatlas.a -Wl,/usr/lib/atlas/libcblas.a
-Wl,/usr/lib/atlas/libblas.a 
  -Wl,/usr/lib/libmysqlclient.so -o test
 Util.o: In function `_D3ccb6matrix4Util11__unittest0FZv':
 Util.d:(.text+0x2ec4): undefined reference to 
 `_D3ccb15MySQLConnection15mysqlConnection7__ClassZ'
 Util.d:(.text+0x2f22): undefined reference to 
 `_D3ccb15MySQLConnection15mysqlConnection5_ctorMFAaAaAaAaZC3ccb15MySQLConnection15mysqlConnection'
 collect2: ld returned 1 exit status

 I am trying to use gdc for its 64-bit compilation, but this is a problem. 
 I checked the compiled code inside MySQLConnection.o with objdump and 
 found that _D3ccb15MySQLConnection15MysqlConnection7__ClassZ exists. The 
 only different between this label and the one that is causing the error is 
 the m in the last term. The name of the class is MysqlConnection.

 I am using gdc (GCC) 4.1.3 20070831 (prerelease gdc 0.25, using dmd 1.021) 
 (Ubuntu 0.25-4.1.2-16ubuntu1).

 What can I do to get this is compile and link?

 Thank you taking to read this,
 JC
I don't see why a single compiler would generate two different mangled names for the same identifier. As such, I wonder where the two object files involved were obtained from? Could they have been built with different compiler versions somehow? Did you obtain one of them as a binary? If so, perhaps the case in the associated extern declaration is incorrect... I also know that DMD acts differently if you compile a series of files in the one command or compile each seperately and the link. Don't think this would apply to GDC but another thought... Good luck
Apr 18 2008