Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7742697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:20:30+00:00 2026-06-01T09:20:30+00:00

I know this has been asked probably a thousand times, but I’ve been biting

  • 0

I know this has been asked probably a thousand times, but I’ve been biting my nails on this one for a few days now. I’m fairly new to C++ and this is my first time using Visual Studio.

I’m trying to modify the TORCS Racing Simulator for a competition at my University. Most of this has already been done, so only parts of what I’m posting is actually my code. But I added some new functions to it and I’m having trouble with them.

The whole thing worked fine in Linux with g++ but when I try to compile it in Visual Studio 2005, I get an Unresolved external symbol error.

I added a new project to the Solution, which uses functions from other projects.

In this new project I call the function:

getisDerbyDuel()

which is declared in raceinit.h, which I included in the new project.

#ifndef _RACEINIT_H_
#define _RACEINIT_H_

#define RACE_ENG_CFG    "config/raceengine.xml"

extern void ReInit(void);
extern void ReShutdown(void);
extern void ReStartNewRace(void * /* dummy */);
extern void ReAddRacemanListButton(void *menuHandle);
extern int  ReInitCars(void);
extern int  ReInitTrack(void);
extern void ReRaceCleanup(void);
extern void ReRaceCleanDrivers(void);
extern char *ReGetCurrentRaceName(void);
extern char *ReGetPrevRaceName(void);
extern bool getisDerbyDuel(void);
extern void setisDerbyDuel(bool isDerbyDuel);

extern tModList *ReRaceModList;

#endif /* _RACEINIT_H_ */

and defined in raceinit.cpp:

 bool _isDerbyDuel = true;

void setisDerbyDuel(bool isDerbyDuel) {
    _isDerbyDuel = isDerbyDuel;
}
bool getisDerbyDuel(void) {
    return _isDerbyDuel;
}

The raceinit.h and raceinit.cpp are in a different projects in my Solution called client, which compiles without errors. I also added the client.lib to the dependencies in my project.

When compiling I get the following output:

1>Generating Code... 
1>Compiling resources...
1>Linking...
1>   Creating library .\Release/championship2010server.lib and object      .\Release/championship2010server.exp
1>championship2010server.obj : error LNK2019: unresolved external symbol "bool __cdecl     getisDerbyDuel(void)" (?getisDerbyDuel@@YA_NXZ) referenced in function "void     __cdecl drive(int,struct CarElt *,struct Situation *)"     (?drive@@YAXHPAUCarElt@@PAUSituation@@@Z)
1>.\Release/championship2010server.dll : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Users\Administrator\Desktop\torcs-verylasttry    \src\drivers\championship2012server\Release\BuildLog.htm"
1>championship2010server - 2 error(s), 9 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========    

Any ideas are appreciated, I don’t know what to try anymore.


EDIT:

Thanks for your answers. I tried changing the external thing, so the flag itself is declared external in the header file and the getter is not (and several combinations) but nothing seems to change the error output.

I’m not exactly sure what is meant by exporting the functions. A quick Google search lead me to this:

[..]
extern void ReRaceCleanDrivers(void);
extern char *ReGetCurrentRaceName(void);
extern char *ReGetPrevRaceName(void);
#ifdef __cplusplus
extern "C" {  // only need to export C interface if
              // used by C++ source code
#endif
extern bool __declspec( dllimport ) getisDerbyDuel(void);
extern void __declspec( dllimport ) setisDerbyDuel(bool isDerbyDuel);

#ifdef __cplusplus
}
#endif
extern bool _isDerbyDuel;
[...]

and

extern "C" {
#include <raceinit.h>
}

Which changed the error Output to this:

1>championship2010server.obj : error LNK2019: unresolved external symbol     __imp__getisDerbyDuel referenced in function "void __cdecl drive(int,struct CarElt *,struct     Situation *)" (?drive@@YAXHPAUCarElt@@PAUSituation@@@Z)
1>.\Release/championship2010server.dll : fatal error LNK1120: 1 unresolved externals

I just don’t know whats wrong here.


EDIT TWO:

So, after reading up on importing/exporting functions I adjusted my code.
The header file, where the unresolved function is declared now looks like this:

#ifdef __cplusplus
extern "C" {  // only need to export C interface if
              // used by C++ source code
#endif
 __declspec( dllexport ) bool getisDerbyDuel(void);
 __declspec( dllexport ) void setisDerbyDuel(bool isDerbyDuel);

#ifdef __cplusplus
}
#endif
extern bool _isDerbyDuel;

The file where I call the function doesn’t have a header file, but I tried to declare the imported function according to the other functions in the file:

[...]
static tTrack *curTrack;
static int RESTARTING[NBBOTS];

static void initTrack(int index, tTrack* track, void *carHandle,
        void **carParmHandle, tSituation *s);
static void newrace(int index, tCarElt* car, tSituation *s);
extern "C" void drive(int index, tCarElt* car, tSituation *s);
static void endrace(int index, tCarElt *car, tSituation *s);
static void shutdown(int index);
static int InitFuncPt(int index, void *pt);

__declspec( dllimport ) bool getisDerbyDuel(void);
[...]

The header is included just like any other and the function is called like this:

if (getisDerbyDuel()) {
[...]

The error output now changed to this:

error LNK2019: unresolved external symbol _getisDerbyDuel referenced in function _drive

So it seems to me that if I just solved some C/C++ compatibility issue (or made it worse, I’m not even sure anymore) but the linker problem remains unchanged.

Any Ideas? I’m kinda put off now, but I need to get this to work, or my Boss is going to be pissed 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:20:32+00:00Added an answer on June 1, 2026 at 9:20 am

    As i said, I’m new to Visual Studio but this is still a little embarassing. I found my error and it actually wasn’t in my code.
    In addition to the linker input etc. i had to add the project containing raceinit.cpp to the references in my new project. That solved my problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this has probably been asked a million times, but how do I
I know this has probably been asked a dozen times, but I am kind
I know this question has probably been asked so many times here, but I
I know this probably has been asked before but I am having issues with
I know this has been asked different ways several times, but I'm just not
I know this has been asked thousands of times but I just can't find
I know this has been asked many times but i'm yet to find a
I know this has been asked many times before, but i still can't seem
I know this has probably been asked before, but I can't find it with
Alright, I know questions like this have probably been asked dozens of times, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.