Share via

Merging libraries

Alessio Galliazzo 21 Reputation points
2021-08-30T12:10:45.43+00:00

Hi Guys,
I have some troubles working with libraries trying to merging a couple together.

I developed static a library based on another one an my goal is to create a single lib containg both.

I can compile the first lib as a static library, I can compile the second lib as a static library too but, after executing:

 LIB.EXE /OUTPUT:test.lib open62541.lib myCppPorting.lib

while linking the library test.lib in a demo program, LINK.EXE fail with unresolved reference to some functions of open62541.lib.

For example: LINK.exe tell about an unresolved reference to __imp_UA_new but dumpbin.exe /symbols test.lib clearly show that UA_new is in the library.

myCppPorting is written in C++, open62541.lib is written in C. I also added in the header of open62541 the extern "C" stuff.

Anyone has some suggestions?

Developer technologies | C++
Developer technologies | C++

A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.

0 comments No comments

Answer accepted by question author

RLWA32 52,571 Reputation points
2021-08-30T15:56:22.93+00:00

Since the unresolved external reference is to __imp_UA_new it could be that the header for the open62541 library has declared the functions with __declspec(dllimport). This would be the case when the header is to be used with an import library for an open62541 DLL, not a static library. Check the open62541 documentation to see if there is a macro that should be set or unset to prevent the use of __declspec(dllimport) in the header when it is to be used with open62541 as a static library.

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.