www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - pragma under linux

reply %u <not possible.com> writes:
Hello,

i try to compile mysql programm with pragma under linux.

pragma(lib,"libmysqlclient.so");

But i get an error message:

dmd mysql_pragma.d mysql.d
gcc mysql_pragma.o mysql.o -o mysql_pragma -m32 -lphobos -lpthread -lm
mysql_pragma.o: In function `_Dmain':
mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x15): undefined reference to `mysql_init'
mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x3f): undefined reference to
`mysql_real_connect'
mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x73): undefined reference to
`mysql_query'
mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x7b): undefined reference to
`mysql_store_result'
mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x84): undefined reference to
`mysql_num_rows'
mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x9c): undefined reference to
`mysql_fetch_row'
mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x141): undefined reference to
`mysql_query'
mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x14f): undefined reference to
`mysql_query'
mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x157): undefined reference to
`mysql_affected_rows'
mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x16c): undefined reference to
`mysql_get_server_info'
mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x183): undefined reference to
`mysql_close'
mysql.o: In function `mysql_fetch_array':
mysql.d:(.gnu.linkonce.tmysql_fetch_array+0x29): undefined reference to
`mysql_fetch_row'
mysql.d:(.gnu.linkonce.tmysql_fetch_array+0x3b): undefined reference to
`mysql_num_fields'
mysql.o: In function `db_fetch_array':
mysql.d:(.gnu.linkonce.tdb_fetch_array+0xd): undefined reference to
`mysql_fetch_row'
mysql.d:(.gnu.linkonce.tdb_fetch_array+0x35): undefined reference to
`mysql_fetch_lengths'
mysql.d:(.gnu.linkonce.tdb_fetch_array+0x4c): undefined reference to
`mysql_num_fields'
mysql.o: In function `db_fetch_assoc':
mysql.d:(.gnu.linkonce.tdb_fetch_assoc+0xd): undefined reference to
`mysql_fetch_row'
mysql.d:(.gnu.linkonce.tdb_fetch_assoc+0x41): undefined reference to
`mysql_fetch_lengths'
mysql.d:(.gnu.linkonce.tdb_fetch_assoc+0x4e): undefined reference to
`mysql_field_seek'
mysql.d:(.gnu.linkonce.tdb_fetch_assoc+0x59): undefined reference to
`mysql_fetch_field'
mysql.o: In function `mysql_fetch_assoc':
mysql.d:(.gnu.linkonce.tmysql_fetch_assoc+0x25): undefined reference to
`mysql_fetch_row'
mysql.d:(.gnu.linkonce.tmysql_fetch_assoc+0x3d): undefined reference to
`mysql_field_seek'
mysql.d:(.gnu.linkonce.tmysql_fetch_assoc+0x48): undefined reference to
`mysql_fetch_field'
collect2: ld returned 1 exit status
--- errorlevel 1

Is this possible.
The goal is to run the programm with


dmd 0.175 version

Thanks
Dec 12 2006
parent reply "John Reimer" <terminal.node gmail.com> writes:
On Tue, 12 Dec 2006 06:47:27 -0800, %u <not possible.com> wrote:

 Hello,

 i try to compile mysql programm with pragma under linux.

 pragma(lib,"libmysqlclient.so");

 But i get an error message:

 dmd mysql_pragma.d mysql.d
 gcc mysql_pragma.o mysql.o -o mysql_pragma -m32 -lphobos -lpthread -lm
 mysql_pragma.o: In function `_Dmain':
 mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x15): undefined reference to  
 `mysql_init'
 mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x3f): undefined reference to
 `mysql_real_connect'
 mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x73): undefined reference to  
 `mysql_query'
 mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x7b): undefined reference to
 `mysql_store_result'
 mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x84): undefined reference to
 `mysql_num_rows'
 mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x9c): undefined reference to
 `mysql_fetch_row'
 mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x141): undefined reference to  
 `mysql_query'
 mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x14f): undefined reference to  
 `mysql_query'
 mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x157): undefined reference to
 `mysql_affected_rows'
 mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x16c): undefined reference to
 `mysql_get_server_info'
 mysql_pragma.d:(.gnu.linkonce.t_Dmain+0x183): undefined reference to  
 `mysql_close'
 mysql.o: In function `mysql_fetch_array':
 mysql.d:(.gnu.linkonce.tmysql_fetch_array+0x29): undefined reference to
 `mysql_fetch_row'
 mysql.d:(.gnu.linkonce.tmysql_fetch_array+0x3b): undefined reference to
 `mysql_num_fields'
 mysql.o: In function `db_fetch_array':
 mysql.d:(.gnu.linkonce.tdb_fetch_array+0xd): undefined reference to
 `mysql_fetch_row'
 mysql.d:(.gnu.linkonce.tdb_fetch_array+0x35): undefined reference to
 `mysql_fetch_lengths'
 mysql.d:(.gnu.linkonce.tdb_fetch_array+0x4c): undefined reference to
 `mysql_num_fields'
 mysql.o: In function `db_fetch_assoc':
 mysql.d:(.gnu.linkonce.tdb_fetch_assoc+0xd): undefined reference to
 `mysql_fetch_row'
 mysql.d:(.gnu.linkonce.tdb_fetch_assoc+0x41): undefined reference to
 `mysql_fetch_lengths'
 mysql.d:(.gnu.linkonce.tdb_fetch_assoc+0x4e): undefined reference to
 `mysql_field_seek'
 mysql.d:(.gnu.linkonce.tdb_fetch_assoc+0x59): undefined reference to
 `mysql_fetch_field'
 mysql.o: In function `mysql_fetch_assoc':
 mysql.d:(.gnu.linkonce.tmysql_fetch_assoc+0x25): undefined reference to
 `mysql_fetch_row'
 mysql.d:(.gnu.linkonce.tmysql_fetch_assoc+0x3d): undefined reference to
 `mysql_field_seek'
 mysql.d:(.gnu.linkonce.tmysql_fetch_assoc+0x48): undefined reference to
 `mysql_fetch_field'
 collect2: ld returned 1 exit status
 --- errorlevel 1

 Is this possible.
 The goal is to run the programm with


 dmd 0.175 version

 Thanks
As far as I know, you still can't use pragma(lib,"") under linux. It's only available in the windows version of dmd. You have two options: 1) Add the following flag to the dmd command line: -L-lmysqlclient 2) use bud (build utility for d) and add the following to your source file: version(build) { pragma( link, libmysqlclient ); } Number 2, I haven't tested on linux for awhile, so I'm not sure if it works. But the build tool documents the availability of that feature. -JJR
Dec 13 2006
parent %u <not possible.de> writes:
Number 2 works.

Thank you.
Dec 13 2006