#### Archived

This topic is now archived and is closed to further replies.

## Recommended Posts

Hello, I have copied some code from the adventure demo into my home grown app ... basically the high level stuff to get a LS level up and running. However I am receiving a link error on the code that I copied. On the following line, within the void DisplayingLevel (void) function: LS_DrawWorld (GameTicks); If I comment the line out, the application links fine, however if I include it I get the follow error message: Linking... TerrainEngine.lib(RenderWorld.obj) : error LNK2001: unresolved external symbol _userlights exeRelease/Main.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. I spent hours last night working on this and was able to find that line above but now I''m stumped. Anyone know what is going on and can help me get past this? Thanks, Tony Cabe

##### Share on other sites
what is there not to understand. it''s saying "_userlights" is not defined. DEFINE IT.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

##### Share on other sites
Thanks for your expert help, but it is defined. If its not defined it gives an error like the following:

Compiling...
Main.cpp
C:\PR4\utility\World\srcMain\Main.cpp(88) : error C2065: ''userlights'' : undeclared identifier
C:\PR4\utility\World\srcMain\Main.cpp(94) : error C2228: left of ''.NumLights'' must have class/struct/union type
Error executing cl.exe.

If you notice its a COMPILE error above, I''m asking about a linking error that, according to the compile, is in TerrainEngine.lib(RenderWorld.obj).

Still stumped,

Tony Cabe

##### Share on other sites
notice how the compile error says "undeclared". that is not "undefined".

here''s how it works when you compile a source file, symbol references do not have a "resolved" address, there for they are "unresolved". when you link object files together, these need to become resolved. if a symbol is not defined then it is "unresolved" and the "linker" returns an error. this does not apply to "dynamic symbols" which get linked at run-time. however, you will get a run-time error if they are not resolved at that point.

you can DECLARE a function "void func(void);" to DEFINE the function you need to give it a body.

i.e.
void func(void)
{
}

these two are not the same thing.

if you can specify if "userlights" is a class, variable, member name, struct, etc. i can probably explain how to solve this problem.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

##### Share on other sites
Hello,

I''m not sure if I have the terminology correct yet, but here goes....

I copied the declaration for userlights from the adventure demo, it looks like this.

PR_LIGHTLIST userlights; /* Holds a list of lights */

PR_LIGHTLIST is a structure. I have it as a global variable just as in the adventure demo. Is this the information you needed?

I''m cofused as to why the link error is in the TerrainEngine.lib?

Thanks for looking at this.

Tony Cabe

##### Share on other sites
ahhh, global variables...

ok, if "userlights" is not defined specifically in the "RenderWorld.obj" source file.

meaning "PR_LIGHTLIST userlights;"

if it is defined in another source file then you will need to include the line "extern PR_LIGHTLIST userlights;".

so the compiler and linker knows that this variable is defined externally from the "RenderWorld.obj" file.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.

##### Share on other sites
The terrain engine (AKA high level engine) uses the userlights structure.

Since you''re using C++ you need to define it using the C naming convention in your .CPP file:

#ifdef __cplusplus
extern "C" {
#endif

// .. define variables referenced by external C sources here
PR_LIGHTLIST userlights;

#ifdef __cplusplus
}
#endif

##### Share on other sites
I thank you both for your kindness and your expert help. I have a better understanding of declaration vs. definition as well as c vs. cpp usage. This problem appears to be solved (or at least it compiles and links), now on to the next.

Thanks again,

Tony Cabe

##### Share on other sites
Chris,

Are there any other variables that need to be defined like this? I am really having a hard time getting the user control section to come into cpp and actually work.

Thanks,

Tony

##### Share on other sites
tcabe...

I''ve been working so hard for the last year trying to get PR incapsulated into some classes that I finally made it.

What are your problems exactly ?....

If it is related to installkbd and other mouse things, I would suggest you to do the following :

1/ In the main cpp file of your project, add the following code if it isn''t yet :

  #ifdef __cplusplusextern "C" {#endif char kbdon[256]; PR_MouseStructData mouse;#ifdef __cplusplus}; // Do not forget the '';'' if not there it do not work.#endif

2/ Then, I suggest that you implement your own DirectInput8 code using one of the available tutorials or samples of the DirectX SDK.

3/ Take a very big caution on how PR works in the Main Window Proc function and try to recreate what you ned from it. That''s a really important point. PowerRender uses this function to handle, for example, viewport resizing when you are in windowed mode.

4/ Take a coffee... ;-)

I may be releasing my wrapper classes dll somewhere if it passes two or three tests before :
1/ it definiively works in any situation,
2/ I make a descent tutorial (even if my code is clear and well documented it needs one)
3/ It needs PR libs to compile cause I don''t want to be a tension for Chris and he disserves to wn his life with that engine. It''s a PR wrapper, not a full 3d engine as he has been working on for a long time now.

France

##### Share on other sites

Its really hard to say what the problem is but I will tell you what I was experiencing.

I have an application that I am working on that has the basic structure to it for a low-level PR application. I wanted to begin using the PR high level engine so I cut/paste the code from the adventure demo.

If I left the file structure intact and did not try to seperate Chris''s original code, it worked fine. However when I tried to restructure it based on my personal preferences with certain routines in certain files and setup all the externs and includes, etc, the program would compile and run, but the result was different. My main problems revolved around user control. Forward went backward, backward went forward and left and right took the camera around in a little circle around the player, but still facing the same direction.

It was very odd. I didn''t change any code, just split it up differently and added the externs and includes. Needless to say, I reworked it yesterday in the same structure Chris had originally and I''m not entirely happy with it but its most likely beyond my current skill level to fix.

Thanks,

Tony

Hi,

##### Share on other sites
Hi,

Thanks for the offer. I have moved all of the code back into its original form so its not a big problem now, however if I ever experience another such issue, I''d be glad to have you take a look. I''m always in favor of learning more and having a 2nd pair of eyes on the problem.

Tony

• ### Forum Statistics

• Total Topics
628378
• Total Posts
2982336

• 10
• 9
• 15
• 24
• 11