how do i link 3rd party lib on windows ?

J

Jacques

Hello there

I'm pretty new to C, so this is probably an elementary question....

I'm trying to write a simple c program that calls a function in a
third party library. I would then like to link this to a dll. The
files that were supplied to me by are :
a .lib file
a .h file
a .dll

So... I've written a simple C program like so :

#include "SecondTry.h"
#include <stdio.h>
#include "jni.h"
#include "qabwved.h"

JNIEXPORT void JNICALL Java_SecondTry_helloWorld(JNIEnv *env, jobject
obj)
{
printf("Hello world !\n");
//calling external lib function...
QABatchWV_Startup(1);
return;
}

I'm using the lcc-win32 compiler / linker on Windows 2000.

It compiles fine with the following command line :

lcc -Id:\j2sdk1.4.2_03\include -Id:\j2sdk1.4.2_03\include\win32
-Id:\dev\c\second_try\java -Id:\dev\Qas_app\C SecondTryImpl.c

The problem starts when trying to link it with :

lcclnk -dll qabwved.lib secondtryimpl.obj -o secondtry.dll

I'm getting the following error :

secondtryimpl.obj .text: undefined reference to
'__imp__QABatchWV_Startup'

The function QABatchWV_Startup is defined in the .h file that I've
received. I assumed that the implementation would be in the .lib that
I've received.

Any ideas ? I've tried a few things already, and am really stuck at
the moment.


Jacques
 
J

Jacques Labuschagne

Jacques said:
Hello there

I'm pretty new to C, so this is probably an elementary question....

You may have more luck on a newsgroup devoted to your compiler/platform.
This is not, strictly speaking, a C or C++ question.

Jacques.
 
C

CBFalconer

Jacques said:
I'm pretty new to C, so this is probably an elementary question....

I'm trying to write a simple c program that calls a function in a
third party library. I would then like to link this to a dll. The
files that were supplied to me by are :
a .lib file
a .h file
a .dll

So... I've written a simple C program like so :

#include "SecondTry.h"
#include <stdio.h>
#include "jni.h"
#include "qabwved.h"

JNIEXPORT void JNICALL Java_SecondTry_helloWorld(JNIEnv *env,
jobject obj)
{
printf("Hello world !\n");
//calling external lib function...
QABatchWV_Startup(1);
return;
}

I'm using the lcc-win32 compiler / linker on Windows 2000.
It compiles fine with the following command line :

lcc -Id:\j2sdk1.4.2_03\include -Id:\j2sdk1.4.2_03\include\win32
-Id:\dev\c\second_try\java -Id:\dev\Qas_app\C SecondTryImpl.c

The problem starts when trying to link it with :

lcclnk -dll qabwved.lib secondtryimpl.obj -o secondtry.dll

I'm getting the following error :

secondtryimpl.obj .text: undefined reference to
'__imp__QABatchWV_Startup'

The function QABatchWV_Startup is defined in the .h file that
I've received. I assumed that the implementation would be in
the .lib that I've received.

lcc-win32 is a non-standard C system, and off-topic on both c.l.c
and c.l.c++. Almost anything crossposted to c.l.c and c.l.c++ is
off-topic on at least one. However this will be on-topic in
comp.compilers.lcc, to which I have cross-posted this and set
followups. Go there for any replies.

c.l.c is devoted to the portable C language only. This does not
include any extensions and/or third party libraries.
 
Joined
Jan 8, 2021
Messages
1
Reaction score
1
Many years later, but for whoever reads :

problem is here :

//calling external lib function...
QABatchWV_Startup(1);


This function return an int, and you make a call implying a void return. That drives the linker to think that it's "void QABatchWV_Startup(int);" and then it fails.

To avoid that, make the call like that :

//calling external lib function...
int retCode = QABatchWV_Startup(1);

Regards, an old timer C coder...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top