473,324 Members | 2,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

DLLs and static libraries

I'm trying to create a dll that reads from a static library that I also wrote.So I have my dll and works fine but when the static library comes in it has problems. first if I add the header for the static library works fine but when I call any function for it it tells me that there is a link error "error LNK2019: unresolved external symbol "

The dll does not include the header of the static library directly, it is included in the interface of the dll, if I add it to the header of the dll I get the same results.

All classes in my static library have a __declspec (dllexport)

So its like this

//dllInterface.h
#include "staticlib.h"

class dllinterface
{
virtual funct1()=0;
virtual funct2()=0;
....
}

//mydll.h
class mydll:public dllinterface
{
funct1();
funct2();
...
}

//mydll.cpp
funct1()
{
callsomefunctionfromStaticLibrary();
}
funct2()
{
.....
}

Basically if I did not have the callsomefunctionfromStaticLibrary() call everything will compile with no errors, when I use anything from the library the compiler(msvs 2005) give me error LNK2019 for every function called from the static library.
Well its my first time making dlls so I'm pretty lost, I can tell you that if I include "staticlib.cpp" in my "mydll.cpp" everything compiles with no problems and the dll runs but I think something bad will happend later using this solution because I dont think that its correct to add a .cpp file into another cpp to fix the problem.
Thanks for your time.

Lars
Sep 22 '06 #1
3 6792
Banfa
9,065 Expert Mod 8TB
A dll is an executable and all symbol (function and variable) references must be defined for it to link successfully.

What you have probably done is left the staticlib.lib file out of the link of the dll.

You build process should be something like

1. Compile static library source files into object files
2. Link static library object files into .lib file
3. Compile dynamic library source files into object files
4. Link dynamic library object files and static library .lib file into a .dll and a .lib
Sep 22 '06 #2
You are right !!.. I was able to link the lib to my dll and works fine thanks a lot.
But now I have another problem , all the global variables and functions in the library are showing as errors error LNK2005: already defined in the dll.obj, when I remove them and just use the classes in the library it works fine.. it there a way around this problems without getting rid of the global variables and functions?.. y tried #ifndef #define #endif and using #pragma once in the library but they dont take care of the global variables and functions....

Thanks for the time
Lars
Sep 23 '06 #3
ok never mind I created a class with static variables and functions and everything compiles smooth, thanks
Sep 23 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: John Hunter | last post by:
I am using distutils to build a python extension module on win32. I initialize the Extension class with a list of libraries with Extension("_gd", , include_dirs=incdirs, library_dirs=libdirs,...
14
by: Brian | last post by:
I have been using lcc-win32 but need to switch over to intel for SIMD/SSE2 stuff. The documentation is pretty limited. It does not say much about the linker other than the fact that you can create...
1
by: Leslaw Bieniasz | last post by:
Cracow, 15.09.2004 Hi, I am writing a big C++ project using BCB 4.0. The project consists of several dlls and exes. Each of the dll is composed of several units (that is cpp files with...
7
by: richard pickworth | last post by:
when I try to run my app. on a different computer, I get an error, that DLLs are missing. How can I make my app. "stand alone"?. I am using VisC++ .Net Express. yours Richard
5
by: Rich | last post by:
Hi there, For a quite big application, I need to get large amount of data within a static library (xxx.lib) and put them in a database (a class, say we call it CData), and then make it...
6
by: Brian Bischof | last post by:
I'm having troubles getting the debugging process to work consistenly for external classes. I got it to work once and then I turned it off. But now I can't get re-enabled. Here is what I'm doing....
2
by: ClydeL | last post by:
Compling a legacy VC6.0 program with the VC2005 compiler used mfc80 dlls. Do these get installed with the .NET runtime or do they need to be installed separately.
7
by: Jeff Lynn | last post by:
Help! I recently upgraded my VS V6 to VS 2005 and was unable to build projects that were perfectly ok under VS V6. Where VS 2005 fails was in the linker resolving external DLLs, which are Open...
4
by: | last post by:
I have learned about compartmentalizing my code base using Class Libraries. I have my common code such as my ORM framework broken out into their own Class Libraries, which are referenced as...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.