www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - (coff)-Implib lib from dll

reply %u <nrgyzer gmail.com> writes:
Hey guys,

I'm trying to connect to my mysql-server on windows. I'm using the mysql
binding from http://www.steinmole.de/d/ because as I know the
DDBI project doesn't support D2.
I followed the instructions on the site and first created the lib file with
implib with the following command: "implib libmysql.lib
libmysql.dll" (without ").
Next, I changed the extern(C) statement in mysql.d to extern(Windows).

Now... I create a simple application with the following source:

module test;

pragma(lib, "libmysql.lib");

import mysql;

int main(string[] args) {

	MYSQL* mysql;
	mysql = mysql_init(null);
	mysql_close(mysql);

	return 0;

}

I'm trying to compile the source file by using the following command:
"dmd -d test.d mysql.d" (without quotas). The result is the following:

test.obj(test)
 Error 42: Symbol Undefined _mysql_init 4
test.obj(test)
 Error 42: Symbol Undefined _mysql_close 4
--- errorlevel 2

I also tried "dmd -d test.d mysql.d libmysql.lib" without any success. When I
remove the extern-statement from mysql.d, I get similar
errors.

Note... I'm using the github-version 0.2.3 which was released last week.

I think my mistake is the linking because the binding works on Linux. But...
not on Windows - perhaps... anyone know how what I'm doing
wrong?

Thanks...
Jan 15 2011
parent reply Mafi <mafi example.org> writes:
Am 15.01.2011 17:07, schrieb %u:
 Hey guys,

 I'm trying to connect to my mysql-server on windows. I'm using the mysql
binding from http://www.steinmole.de/d/ because as I know the
 DDBI project doesn't support D2.
 I followed the instructions on the site and first created the lib file with
implib with the following command: "implib libmysql.lib
 libmysql.dll" (without ").
 Next, I changed the extern(C) statement in mysql.d to extern(Windows).

 Now... I create a simple application with the following source:

 module test;

 pragma(lib, "libmysql.lib");

 import mysql;

 int main(string[] args) {

 	MYSQL* mysql;
 	mysql = mysql_init(null);
 	mysql_close(mysql);

 	return 0;

 }

 I'm trying to compile the source file by using the following command:
 "dmd -d test.d mysql.d" (without quotas). The result is the following:

 test.obj(test)
   Error 42: Symbol Undefined _mysql_init 4
 test.obj(test)
   Error 42: Symbol Undefined _mysql_close 4
 --- errorlevel 2

 I also tried "dmd -d test.d mysql.d libmysql.lib" without any success. When I
remove the extern-statement from mysql.d, I get similar
 errors.

 Note... I'm using the github-version 0.2.3 which was released last week.

 I think my mistake is the linking because the binding works on Linux. But...
not on Windows - perhaps... anyone know how what I'm doing
 wrong?

 Thanks...

leading underscores? I had a similar problem and that solved it for me.
Jan 15 2011
next sibling parent reply nrgyzer <nrgyzer gmail.com> writes:
I just used "implib libmysql.lib libmysql.dll /system" but it produces
the same errors.
Jan 15 2011
parent reply Mafi <mafi example.org> writes:
Am 15.01.2011 17:46, schrieb nrgyzer:
 I just used "implib libmysql.lib libmysql.dll /system" but it produces
 the same errors.

In the implib help it says: "implib [switches] libfile [ dllfile | deffile ]" I'm not sure but implib could be picky about where the switches are. Mafi
Jan 15 2011
parent reply Nrgyzer <nrgyzer gmail.com> writes:
Thanks, but didn't help to change to "implib /system libmysql.lib
libmysql.dll"  - some errors.
Jan 15 2011
parent Nrgyzer <nrgyzer gmail.com> writes:
This solved the problems, thanks - but, when the line "mysql =
mysql_init(null);" produces an access violation.
Jan 15 2011
prev sibling parent Jimmy Cao <jcao219 gmail.com> writes:
--0016e64c16e0b11b6c0499e65634
Content-Type: text/plain; charset=ISO-8859-1

Try this:

implib /s libmysql.lib libmysql.dll

Then change extern(Windows) to extern(C).

(That's how I usually have it set up)

--0016e64c16e0b11b6c0499e65634
Content-Type: text/html; charset=ISO-8859-1

Try this:<br><br>implib /s libmysql.lib libmysql.dll<br><br>Then change
extern(Windows) to extern(C).<br><br>(That&#39;s how I usually have it set
up)<br>

--0016e64c16e0b11b6c0499e65634--
Jan 15 2011