MSVS Linker doesn't find symbol

102 Views Asked by At

I am having trouble with the Linker in VS2022. Basically I have a class, some functions in a "raw" file and some functions in a namespace. There is a small description (non exhaustive)

Embree (static lib)

  • API.h
  • Embree.h (with getIntersection_RayHit declaration)
  • API.cpp
  • Embree.cpp (with getIntersection_RayHit definition)

LibEmbree (static lib)

  • LibEmbree.h
  • LibEmbree.cpp

TestLibEmbree (executable)

  • TestLibEmbree.cpp (needs both libraries)

When building the project, I have the following error (there is actually a lot more errors, for a few different functions) :

1>TestLibEmbree.obj : error LNK2019: symbole externe non résolu "struct RayHit __cdecl getIntersection_RayHit(struct RTCSceneTy * const,float const *,float const *)" (?getIntersection_RayHit@@YA?AURayHit@@QEAURTCSceneTy@@PEBM1@Z) référencé dans la fonction "void __cdecl testPhil3(void)" (?testPhil3@@YAXXZ)

However intellisense is auto-completing for those functions and I have no problems (nothing underlined or red) when coding.

I saw a lot of similar issues on this platform but none of the fixes I tried actually fixed the problem. This is possibly a duplicate however none of the other questions I found were actually similar (not the same configuration or version of MSVS). I believe I do have the right #include for the "TestLibEmbree" file (that contains testPhil3), for example :

#include "../Embree/Embree.h"

Do any of you have an idea to solve this issue ?

Thanks a lot for your help.

1

There are 1 best solutions below

2
Arolan On

I found a way to solve my problem. I don't really know why for some of my libraries it is not needed.

Go to your project properties->Linker->Input->Additional Dependencies and add the full path to the .lib (usually in the x64/Release or /debug folder).

And then, magically, it works.