简体   繁体   中英

link static library in c++ visual studio

can someone please help me to understand the process.

in c++ visual studio 2010

i have a visual studio solution (lets call it mysol)

i have a project built as a static library (let's call it staticprj) staticprj needs to use a library from outside (lets call it ext.lib)

in the body of the source code of staticprj i include outside library header file with # include extlib.h and make calls to some of its functions (let call them extfunctions()) i also include the the path to the header files location of the ext.lib.

the staticprj compiles okay without errors

the mysol also has another project which is a dynamic library (dynprj) and which depends on the staticprj.

also in the source files of the dynprj uses functions from outside library.

i have included #include extlib.h in the source code of dynprj. i have included the path of the header files i have attached extlib.h directly to the dynprj i have also added ext.lib to the linker input (along with the path where the ext.lib resides).

i still get a lnk2001 error stating that extfunctions() where not found.

the whole structure (the mysol solution) compiles okay if i do not use ext.lib at all.

my question is how does the linking process works and what can i do to correct this linking error.

(note that without the presence of ext.lib my linking of the staticprj and dynprj is fine. my compilation works okay and my code works. i only get the linking error when i try to link another ext.lib to staticprj and dynprj and use functions from ext.lib)

thanks in advance.

I'm not quite sure it will work, but try putting the .dll inside your "mysol" debug folder. I had a similar problem couple of weeks ago when I had library compiled as .dll. I just placed that .dll within my debug folder and worked lovely.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM