Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Calling client's functions from a Win32 dll

ballyaballya Member Posts: 6
Hi All,
I have a problem while coding my program. Here is the situation:
I have a code running fine on Unix/Linux that is to be ported on Windows.
There is one dll and a client program. The main program (exe) has a common function (LogMessage()) used for logging. The same function needs to be called from the dll for logging dll messages.
On unix its easily done by shared library (using -fPIC & other stuff). However, on windows I am getting linking errors for this function. I am using vc++ 6.0.
The program compiles fine but fails during linking. The linker says:- error LNK2001: unresolved external symbol

Can anybody tell me how to solve this problem?

-ballya

Comments

  • rollerolle Member Posts: 115
    : Hi All,
    : I have a problem while coding my program. Here is the situation:
    : I have a code running fine on Unix/Linux that is to be ported on Windows.
    : There is one dll and a client program. The main program (exe) has a common function (LogMessage()) used for logging. The same function needs to be called from the dll for logging dll messages.
    : On unix its easily done by shared library (using -fPIC & other stuff). However, on windows I am getting linking errors for this function. I am using vc++ 6.0.
    : The program compiles fine but fails during linking. The linker says:- error LNK2001: unresolved external symbol
    :
    : Can anybody tell me how to solve this problem?
    :
    : -ballya
    :
    [green]you need to include a lib file (with the log function) in the project or make file.
    Q1:Which proggy gives the compiler error - exe or dll?
    Q2:Why don't you put the log funtion in the DLL instead?[/green]

  • abcabc Member Posts: 443
    : : Hi All,
    : : I have a problem while coding my program. Here is the situation:
    : : I have a code running fine on Unix/Linux that is to be ported on Windows.
    : : There is one dll and a client program. The main program (exe) has a common function (LogMessage()) used for logging. The same function needs to be called from the dll for logging dll messages.
    : : On unix its easily done by shared library (using -fPIC & other stuff). However, on windows I am getting linking errors for this function. I am using vc++ 6.0.
    : : The program compiles fine but fails during linking. The linker says:- error LNK2001: unresolved external symbol
    : :
    : : Can anybody tell me how to solve this problem?
    : :
    : : -ballya
    : :
    : [green]you need to include a lib file (with the log function) in the project or make file.
    : Q1:Which proggy gives the compiler error - exe or dll?
    : Q2:Why don't you put the log funtion in the DLL instead?[/green]
    :

    if the log function is in a separate dll you need the lib for that dll linked in. if you don't have the lib, find the function signature, dynamically load the dll and get the function's address (kind of like dlopen()+dlsym() ).
  • ballyaballya Member Posts: 6
    Thanks for the reply.
    There was not any compiler error. only linker error. and Thats for the dll.
    I have already worked out the similar solution. From the exe I export the function and in DLL import it. the .lib is used while building the dll. It works now.

    : : Hi All,
    : : I have a problem while coding my program. Here is the situation:
    : : I have a code running fine on Unix/Linux that is to be ported on Windows.
    : : There is one dll and a client program. The main program (exe) has a common function (LogMessage()) used for logging. The same function needs to be called from the dll for logging dll messages.
    : : On unix its easily done by shared library (using -fPIC & other stuff). However, on windows I am getting linking errors for this function. I am using vc++ 6.0.
    : : The program compiles fine but fails during linking. The linker says:- error LNK2001: unresolved external symbol
    : :
    : : Can anybody tell me how to solve this problem?
    : :
    : : -ballya
    : :
    : [green]you need to include a lib file (with the log function) in the project or make file.
    : Q1:Which proggy gives the compiler error - exe or dll?
    : Q2:Why don't you put the log funtion in the DLL instead?[/green]
    :
    :

  • Chris BrownChris Brown USAMember Posts: 4,624 ✭✭

    \ http://forcoder.org \ free video tutorials and ebooks about || Python, Swift, C#, PL/SQL, R, Ruby, Go, Assembly, Visual Basic .NET, Delphi, Visual Basic, C++, JavaScript, Objective-C, Perl, Java, PHP, MATLAB, Scratch, C Ada, COBOL, Rust, Hack, Scheme, ML, LabVIEW, Erlang, D, Crystal, F#, Fortran, VBScript, Kotlin, ABAP, SAS, Logo, Bash, FoxPro, Julia, Alice, Scala, Dart, Lua, Clojure, Prolog, Apex, Lisp, Awk, Transact-SQL || _

Sign In or Register to comment.