Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 445
  • Last Modified:

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

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
John500
Asked:
John500
  • 3
1 Solution
 
jkrCommented:
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
 
John500Author Commented:
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
 
jkrCommented:
You're welcome :o)
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now