Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VC5: .c vs .cpp Compiling/Linking: Unresolved Externals

Posted on 1998-08-12
2
Medium Priority
?
267 Views
Last Modified: 2010-04-10
I have a .c file which compiles and links fine. When I compile and link this file with the /Tp option to specify it to be compiled as a C++ file the link fails with the error: LNK2001 unresolved external symbol. The .lib which contains the implementation of the function I am trying to use matches with a .dll which was written in visual basic. Any ideas?
0
Comment
Question by:wewesb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
snoegler earned 60 total points
ID: 1170036
The point is that c++ function names get 'mangled' when building the .obj files.
'dumpbin' your c++ object file and your c object file and compare them, then you'll see
what i mean. To avoid this, declare the functions with like this:
void _declspec("C") my_func()
This tells the compiler even if compiling c++ files to use the 'c' naming scheme.
0
 

Author Comment

by:wewesb
ID: 1170037
Ah yes, that led me to a solution. I first tried void _declspec("C") my_func() but I got a syntax error complaining about "string". I changed the syntaxt to "C" void my_func() and it compiled and linked fine. Thanks!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Article by: evilrix
Looking for a way to avoid searching through large data sets for data that doesn't exist? A Bloom Filter might be what you need. This data structure is a probabilistic filter that allows you to avoid unnecessary searches when you know the data defin…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question