473,395 Members | 1,790 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,395 software developers and data experts.

VC Linker Problem

I have C99 code (which I changed extensions to .cpp to compile as C+
+98). Which is does fine.

I create a Static Library Project (.lib) and Build, and it builds
the .obj files (9 of them) and makes the .lib.

I change the project to a Dynamic Linked Library (.dll), and then try
to compile and it makes all the .obj files, but fails with making the
DLL with a LINKER ERROR.

clib.obj : error LNK2019: unresolved external symbol _timer referenced
in function "void __cdecl cls_aprod(struct CLS *,int,int,int *
const,double * const,double * const)" (?
cls_aprod@@YAXPAUBCLS@@HHQAHQAN2@Z)
cls.obj : error LNK2001: unresolved external symbol _timer
clsqr.obj : error LNK2001: unresolved external symbol _timer
Debug\cls.dll : fatal error LNK1120: 1 unresolved externals

I exclude a few of the .cpp files that reference the timer function,
and re-build, and I get LNK errors again about other functions that
are in the project, but not in that .obj file (ie functions that
reference the other name.cpp files through the #include name.h ).

It seems like the DLL is not linking the functions from the other .cpp
files in the folder. If i remove everything and just try to make a
dll with 1 of the files (that do not reference any other functions)
like timer.cpp, it will make the timer.dll fine.

Once I try to make a DLL from a file like cls.cpp (which refrences the
timer.h) it fails with the __timer external symbol unresolved.
But it manages to link them all together fine with the Static Library
(.lib) project? How can I get this to compile as a DLL if I wish to?
How do I tell Visual Studio to make the dll with linking to the other
files in the project like the lib does?

I have played around with some of the options in the DLL Properties >
Linker >(General/Input) tabs... but no success.

Thanks!
Mar 4 '08 #1
2 1403
"NvrBst" <nv****@gmail.comwrote in message
news:48**********************************@u10g2000 prn.googlegroups.com...
But it manages to link them all together fine with the Static Library
(.lib) project? How can I get this to compile as a DLL if I wish to?
How do I tell Visual Studio to make the dll with linking to the other
files in the project like the lib does?
I think that you've hit on the head on the nail there: static libraries are
not linked, and there's no requirement that internal references be satisfied
within the library. A library is not significantly different from a ZIP
file containing a bunch of OBJ files. In contrast, a DLL is a linked image
and there cannot be any unsatisfied symbol references.

So, it sounds like you're missing a definition for _timer in your code -
something needs to supply that reference.

-cd

Mar 5 '08 #2
On Mar 4, 8:29 pm, "Carl Daniel [VC++ MVP]"
<cpdaniel_remove_this_and_nos...@mvps.org.nospamwr ote:
"NvrBst" <nvr...@gmail.comwrote in message

news:48**********************************@u10g2000 prn.googlegroups.com...
But it manages to link them all together fine with the Static Library
(.lib) project? How can I get this to compile as a DLL if I wish to?
How do I tell Visual Studio to make the dll with linking to the other
files in the project like the lib does?

I think that you've hit on the head on the nail there: static libraries are
not linked, and there's no requirement that internal references be satisfied
within the library. A library is not significantly different from a ZIP
file containing a bunch of OBJ files. In contrast, a DLL is a linked image
and there cannot be any unsatisfied symbol references.

So, it sounds like you're missing a definition for _timer in your code -
something needs to supply that reference.

-cd
Hello;

the definition for the timer function is in a timer.cpp file in the
code. Which was included in the project... so I was confused.
But I ended up finding the problem, i was including bctimer.h from
another header file. And it had a:
#ifdef __cplusplus
extern "C" {
#endif
....
#include "bctimer.h"
....
#ifdef __cplusplus
}
#endif
This was what was causing the problem and making it not link the
bctimer stuff with the dll... however i was able to "compile" the
object files fine... so it was seeing the header information from
bctimer.h... just wsn't using it for linking.

Removing the #ifdef __cplusplus extern "C" { ... stuff made it
work. I can compile the .DLL and the .LIB files fine now! thanks for
all your help!
Mar 5 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: haplotype | last post by:
I have designed a package with several files, which is listed bellow base.cpp & base.hpp - define the template class base tree.cpp & tree.hpp - define the class tree derived from base<int>...
3
by: Georg | last post by:
Hello, I must be doing something wrong, but I don't get it: - compile gcc -c -O -Iinc src/hello.c -o obj/hello.o gcc -c -O -Iinc src/msg_1.c -o obj/msg_1.o gcc -c -O -Iinc src/msg_2.c -o...
2
by: Joske | last post by:
Hi, I'm having a similar problem as Scott. A static library with managed C++ functions fails to link in. See http://groups.google.be/groups?q=managed+C%2B%...
4
by: Saran | last post by:
Hi All, I'm getting the following linker error when I try to build a library. nafxcw.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argv nafxcw.lib(appcore.obj) : error...
3
by: Steve Baer | last post by:
I recently read your whitepaper under the "extremely long link times" post and have a question that I was hoping you could answer. My question is based on the following paragraph: Directives...
9
by: Peter Oliphant | last post by:
For some reson my code is generating a LNK1215 error, which 'suggests' I re-install VS C++. So I did. which did NOT solve the problem. The weid part is it seems to be caused by my one CPP file, but...
3
by: ralphsieminsky | last post by:
A project compiles fine under VS 2005 RC without the /clr option. However, when /clr is turned on several errors appear: - A symbol exported from a DLL is not found by another DLL referencing...
1
by: Felix | last post by:
After porting a project from VC6 to VC.NET 2003 I have a very strange problem generating link error 1104 for import libraries. I just ported the project and made some small adaptions so it fits...
2
by: Robbie Hatley | last post by:
"Victor Bazarov" <v.Abazarov@comAcast.net> wrote: > Robbie Hatley wrote: > > > > I ran into a problem a few days ago when I added a couple of > > template functions to one of my personal...
1
by: Deepath G | last post by:
This is deepath.. I am getting some linker error when i am trying to connect Websphere MQ using Borland C++ Builder 2006 using imqi.hpp on windows. Error Message ----------------------- ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.