?
Solved

Can't compile a  VS C++  project using the exact same files and settings as a   VS C   project  -   ( linker errors ) ??

Posted on 2003-03-18
4
Medium Priority
?
419 Views
Last Modified: 2008-02-01
Greetings,

I have a Sybase project coded in 'C' but I need to compile it in C++.  After various attempts using different workspaces (i.e. Win32 App/Win Console) and different source files (C/C++) I always end up with the same linker errors.  The original C project is a Console application but I need a Win32 app done in C++.  The Win32 app will compile as long as I stipulate the source files to be in 'C'.  Thus, I've concluded the sole problem is due to making the project a C++ application.  Here are my errors:

error LNK2001: unresolved external symbol "long __stdcall ex_ctx_cleanup(struct _cscontext *,long)" (?ex_ctx_cleanup@@YGJPAU_cscontext@@J@Z)
error LNK2001: unresolved external symbol "long __stdcall ex_con_cleanup(struct _csconnection *,long)" (?ex_con_cleanup@@YGJPAU_csconnection@@J@Z)
error LNK2001: unresolved external symbol "long __stdcall ex_connect(struct _cscontext *,struct _csconnection * *,char *,char *,char *,char *)" (?ex_connect@@YGJPAU_cscontext@@PAPAU_csconnection@@PAD222@Z)
error LNK2001: unresolved external symbol "void __stdcall ex_panic(char *)" (?ex_panic@@YGXPAD@Z)
error LNK2001: unresolved external symbol "long __stdcall ex_init(struct _cscontext * *)" (?ex_init@@YGJPAPAU_cscontext@@@Z)
error LNK2001: unresolved external symbol "long __stdcall ex_fetch_data(struct _cscommand *)" (?ex_fetch_data@@YGJPAU_cscommand@@@Z)
error LNK2001: unresolved external symbol "void __stdcall ex_error(char *)" (?ex_error@@YGXPAD@Z)
error LNK2001: unresolved external symbol "long __cdecl ex_use_db(struct _csconnection *,char *)" (?ex_use_db@@YAJPAU_csconnection@@PAD@Z)
fatal error LNK1120: 8 unresolved externals

I tried not using 'precompiled' header files but it didn't make a difference.  Bottom line, I want to use the Sybase code for database connectivity and the C++ code for more powerful operations than I would otherwise have in C.  How can I get this compiled ????
0
Comment
Question by:John500
[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
  • 3
4 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 8159338
Put a

#ifdef __cplusplus
extern "C" {
#endif

// include Sybase headers here...

#ifdef __cplusplus
}
#endif

construct around your inclusion of the Sybase header files. Otherwise, the compiler will assume C++ and decorate the symbol names the C++ way.
0
 
LVL 86

Expert Comment

by:jkr
ID: 8159368
0
 

Author Comment

by:John500
ID: 8160929
jkr,

Wow, that did the trick!  Thanks.

My current task has various pieces to it and this question handles activity which occurs after the 'directory watcher' discovers a change in the specified directory.

My tasks are this:

1)  The service    // done
2)  The GUI to display the directory  // not done
3)  Database transaction based on directory contents // compiled

I had every intention of getting back to you on the other question because I still have to finish it.  I just couldn't seem to get that off the ground.  Now that this is compiled, I'll finish the other.  Thanks.






0
 
LVL 86

Expert Comment

by:jkr
ID: 8161010
You're welcome :o)
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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…
Suggested Courses

771 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