0

I'm trying to build a project with the MSVC compiler (cl.exe), the command is

start /b /wait "" "cl.exe" %build_options% %compile_flags% ..\src\win32_main.cpp /link /LIBPATH:..\src\ %link_flags% /out:%application_name%

I have set LIBPATH to where the cpp implementations to my headers are but all I get is an unresolved external. Note, I have no problem running my project without cpp files (meaning everything being inside a header, included in my main and worked through there, the problem is that the linker can't find the implementation of .h files).

Any help would be appreciated, thanks! my files are structured like so

MSalters
  • 173,980
  • 10
  • 155
  • 350
  • Does this answer your question? [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – kesarling He-Him Sep 15 '20 at 08:38
  • Not exactly, I kinda know the compilation steps, my main problem is that I don't know how I can set the LIBPATH in the MSVC Compiler. The unresolved external is probably there because the path is wrong somehow. – user14279931 Sep 15 '20 at 08:40

1 Answers1

1

The direct problem that you have is that you need to link *.obj files, or possibly *.lib files built from those .obj files, but definitely not .cpp files.

I suggest that you stick with Visual Studio. The root cause of your problem is that you're reinventing the wheel. The MSVC compiler is designed to be called by a build environment.

MSalters
  • 173,980
  • 10
  • 155
  • 350