- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello!
I have a little problem with a static lib here.
When I compile a console test program that uses it I get the following error:
Test.obj : error LNK2019: unresolved external symbol __imp_MethodName referenced in function _TESTMODULE_mp_EXECUTETEST
A dumpbin of my obj file gives me the expected:
03B 00000000 UNDEF notype External | __imp_MethodName
A dumpbin of my static lib shows:
00A 00000006 SECT1 notype () External | MethodName
03E 00000000 SECT4 notype Static | MethodName$FUNCTNAME
Where does the "__imp_" come from ? And how do Iget rid of it.
Thanks in advance and sorry for my poor english.
I have a little problem with a static lib here.
When I compile a console test program that uses it I get the following error:
Test.obj : error LNK2019: unresolved external symbol __imp_MethodName referenced in function _TESTMODULE_mp_EXECUTETEST
A dumpbin of my obj file gives me the expected:
03B 00000000 UNDEF notype External | __imp_MethodName
A dumpbin of my static lib shows:
00A 00000006 SECT1 notype () External | MethodName
03E 00000000 SECT4 notype Static | MethodName$FUNCTNAME
Where does the "__imp_" come from ? And how do Iget rid of it.
Thanks in advance and sorry for my poor english.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Look for compiler directives in your sources that declare MethodName as a DLLIMPORT. Remove or comment out the directive, if you want to link statically to the routine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello!
I searched my sources for DLLIMPORT and found nothing.
Wrong search term?
BTW: I also build the above Lib as a DLL and use it with my Testprogram. This works fine for me.
I searched my sources for DLLIMPORT and found nothing.
Wrong search term?
BTW: I also build the above Lib as a DLL and use it with my Testprogram. This works fine for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello again!
I want to build my sources as a static lib AND as a DLL.
When I build my sources as LIB everything now is fine.
When I Build it as a DLL I get the following error message types:
error LNK2019: unresolved external symbol _MODULENAME_mp_METHODNAME
Now I change my source and add !DEC$ ATTRIBUTES DLLEXPORT :: MethodName
Now my DLL builds fine.
But my static lib gives me an error like:
error LNK2019: unresolved external symbol __imp_MethodName referenced in function ...
How do I get both to work?
I want to build my sources as a static lib AND as a DLL.
When I build my sources as LIB everything now is fine.
When I Build it as a DLL I get the following error message types:
error LNK2019: unresolved external symbol _MODULENAME_mp_METHODNAME
Now I change my source and add !DEC$ ATTRIBUTES DLLEXPORT :: MethodName
Now my DLL builds fine.
But my static lib gives me an error like:
error LNK2019: unresolved external symbol __imp_MethodName referenced in function ...
How do I get both to work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Create two separate projects, one that builds the static lib and the other builds the DLL. In both projects, add your source files (a source file can be in multiple projects).
In the source file you can conditionally compile the DLLEXPORT directive, so that when you are building the static lib the DLLEXPORT directive is not active. The _DLL symbol is defined when a DLL is being built.
SUBROUTINE MyFunction
!DEC$ IF DEFINED(_DLL)
!DEC$ ATTRIBUTES DLLEXPORT :: MyFunction
!DEC$ ENDIF
Alternatively, your DLL could be a thin forwarding wrapper around the functions in the static lib. The DLL then links to the static lib. Requires that you write the wrapper code though.
In the source file you can conditionally compile the DLLEXPORT directive, so that when you are building the static lib the DLLEXPORT directive is not active. The _DLL symbol is defined when a DLL is being built.
SUBROUTINE MyFunction
!DEC$ IF DEFINED(_DLL)
!DEC$ ATTRIBUTES DLLEXPORT :: MyFunction
!DEC$ ENDIF
Alternatively, your DLL could be a thin forwarding wrapper around the functions in the static lib. The DLL then links to the static lib. Requires that you write the wrapper code though.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page