error LNK2019

121 views
Skip to first unread message

Prabasgarage

unread,
Feb 26, 2024, 6:25:00 AM2/26/24
to ProjectChrono
Hi all,

I am trying to create my very simple first project in chrono where a I just wanted to replace the gator vehicle in the demo_VEH_Gator.cpp with a MAN 5t truck. While building the project I am getting around 56 error LNK2019. I have attached my code and error in the text file below. Any help is highly appreciated. 

my_example.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > __cdecl chrono::vehicle::GetDataFile(c
lass std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (__imp_?GetDataFile@vehicle@chrono@@YA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AEBV34@@Z
) referenced in function main [D:\chrono\chrono\man\build\my_demo.vcxproj]

The chrono.txt

Dario Mangoni

unread,
Feb 26, 2024, 7:36:29 AM2/26/24
to ProjectChrono
Hi Prabas,
there might be a couple of issues:
  • it seems that you didn't call SetChronoDataPath(CHRONO_DATA_DIR);
  • if the issue persists it might be due to a wrong linking to VisualStudio runtime libraries (but that's assumes that you are on Windows, with VisualStudio and you are compiling in Debug mode).
    if so, please make sure to have the most recent version of Chrono: I indeed pushed a fix to a very similar issue with commit e9050235 on February 13th
    If you have a clone of Chrono older than this date, you might see that right-clicking on your project target, in Properties>C/C++>Code Generation, for the Configuration: Debug, you may see that the runtime library is wrongly set to Multi-threaded DLL (/MD) instead of Multi-threaded Debug DLL (/MDd)
If this doesn't solve your problem you may want to share your CMakeCache and the log of the CMake run of your project.

Dario

Prabasgarage

unread,
Feb 26, 2024, 10:12:59 AM2/26/24
to ProjectChrono
Hi Dario,

Thanks a lot. Yes the Problem was I did not set the CHRONO_DATA_DIR variable. After adding line "set(CHRONO_DATA_DIR D:/chrono/chrono/data)" and including Vehicle component in find_package(). I am able to build my project successfully. 

I hope I am using the latest branch of chrono. because git branch command outputs main*. 

Now that my project is built successfully but when I run the exe file I am getting the following error and the UI crashes. Any Idea with this?


chrono build crash.png

Dario Mangoni

unread,
Feb 26, 2024, 2:38:48 PM2/26/24
to ProjectChrono
Ah, that's not the error I was mentioning. If you forgot to add Vehicle module that's a totally different story.
I think you are also missing vehicle::SetDataPath(CHRONO_VEHICLE_DATA_DIR);
Anyway: you are in Debug mode. You can easily understand what is causing you issues. Please take your time to investigate these kind of errors before posting.


Reply all
Reply to author
Forward
0 new messages