Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler error LNK2019 #71

Open
Programmer54 opened this issue Jun 8, 2022 · 3 comments
Open

Compiler error LNK2019 #71

Programmer54 opened this issue Jun 8, 2022 · 3 comments

Comments

@Programmer54
Copy link

After making some very minor changes (which I had to do to get the sdk to work), when I try to compile I get this error:

1:
Severity Code Description Project File Line Hide Status
Error LNK2019 unconverted outer symbol "struct sl::Result<class sl::IChannel *> __cdecl sl::createSerialPortChannel(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,int)" (?createSerialPortChannel@sl@@ya?AU?$Result@PEAVIChannel@sl@@@1@AEBV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D @2@@std@@h@Z) referenced at your parent ConsoleApplication1

2:
Severity Code Description Project File Line Hide Status
Error LNK2019 unresolved external symbol "struct sl::Result<class sl::ILidarDriver *> __cdecl sl::createLidarDriver(void)" (?createLidarDriver@sl@@ya?AU?$Result@PEAVILidarDriver@sl@@@1@ XZ) referenced in main function ConsoleApplication1

NOTE:
The examples that come with the sdk are not compiled, but the project required for the .lib file is compiled. So, I have a compiled file "rplidar_driver.lib" and the LIBRARY setting has been made for the project.

@Programmer54 Programmer54 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 13, 2022
@Ajasra
Copy link

Ajasra commented Jan 12, 2023

Do you solve this problem? I have the same. Looks like the version of the rplidar_driver and linking it.

@Programmer54
Copy link
Author

I stopped looking at this project a long time ago. But I think I solved this problem by setting the generated code attribute when linking the library. as follows:
Project properties > Refinement > Generate Code During Linking => I set this property but I couldn't remember which one I chose. You can learn this value from the sample project in the lidar sdk. I hope I was helpful, if your problem persists please feel free to write :) Good work

@Programmer54 Programmer54 reopened this Jan 12, 2023
@Ajasra
Copy link

Ajasra commented Jan 13, 2023

Solved. There are a few steps. The Visual Studio configuration manager can get into some trouble with it.

  1. Add the 'rplidar_driver' from the SDK into your solution as dependence.
    • Solution - Add - Existing project
    • _Solution - Dependency - select 'rplidar_driver" project.
      9401c968bd75ed68417a8047ad2fed6
  2. Properties - C/C++ - General - Additional include directories (add the directory with /sdk, /sdk/include, /sdk/src in relation to your folder structure)
    image
  3. Properties - Linker - General - Additional Library Directories (add here the path to where 'rplidar_driver' build .lib file)
    image
  4. Properties - Linker - Input - Additional Dependencies (add 'rplidar_driver.lib')
    image
  5. Properties - C/C++ - Code Generator - Runtime library (be sure both your project and rplidar_driver have the same option there, I used /MTd)
    image
  6. Now we need to change the rplidar_driver to x64; in the configuration manager, there are bugs; it does not let you create an x64 solution for rplidar_driver if you already have x64 dilution in your project (say a solution with this name already exist). So, I need to delete the x63 option first and after adding it again everywhere)
  • Properties - Configuration manager
  • delete x64 platform for all projects and delete the x64 solution
    image
  • add x64 platform to rplidar_driver, add x64 platform to your project (uncheck 'create a new solution platform)
    image
  • add x64 solution to 'Active solution platform'
    image
  • select all projects to have the same platform (for me, I needed to do this process two times. The first time x64 just did not appear in the list after I added it. So I needed to delete all x64 platforms and solutions and restart Visual Studio)
    image

Then I was able to build both driver and my project in x64 without errors.
Thanks to Tamaya31 for help and direction to look into.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants