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

[windows] error linking pcl rangeimage LNK2020 LNK2001 LNK1120 #807

Open
fbenavidesd opened this issue Jul 21, 2014 · 8 comments
Open

[windows] error linking pcl rangeimage LNK2020 LNK2001 LNK1120 #807

fbenavidesd opened this issue Jul 21, 2014 · 8 comments
Labels
kind: compile error Type of issue needs: testing Specify why not closed/merged yet platform: windows

Comments

@fbenavidesd
Copy link

I have a visual C++ project of Dynamic
Library (.dll) type. This is beacuse I want to use that C++ dll that I
build from a C# project. I use your PCL library 1.6 and it works well.
The problem appears when I include the range_image.h . The problem is that
the RangeImage class have

static const int lookup_table_size;
static std::vector asin_lookup_table;
static std::vector atan_lookup_table;
static std::vector cos_lookup_table;

and they are referenced by static inline method, an when you compile
it like a .dll using the Common Language Runtime Support (/clr) it
gives these errors

Error   80  error LNK2020: unresolved token (0A003A6D) "protected: static 
class std::vector<float,class std::allocator<float> > 
pcl::RangeImage::asin_lookup_table" 
(?asin_lookup_table@RangeImage@pcl@@1V?$vector@MV?$allocator@M@std@@@std@@A) 

Error   79  error LNK2020: unresolved token (0A003A6C) "protected: static 
int const pcl::RangeImage::lookup_table_size" 
(?lookup_table_size@RangeImage@pcl@@1HB) 

Error   78  error LNK2020: unresolved token (0A003A6B) "protected: static 
class std::vector<float,class std::allocator<float> > 
pcl::RangeImage::atan_lookup_table" 
(?atan_lookup_table@RangeImage@pcl@@1V?$vector@MV?$allocator@M@std@@@std@@A) 

Error   77  error LNK2020: unresolved token (0A003A6A) "protected: static 
class std::vector<float,class std::allocator<float> > 
pcl::RangeImage::cos_lookup_table" 
(?cos_lookup_table@RangeImage@pcl@@1V?$vector@MV?$allocator@M@std@@@std@@A) 

Error   81  error LNK2001: unresolved external symbol "public: virtual 
void __cdecl pcl::RangeImage::getSubImage(int,int,int,int,int,class 
pcl::RangeImage &)const " 
(?getSubImage@RangeImage@pcl@@UEBAXHHHHHAEAV12@@Z) 

Error   82  error LNK2001: unresolved external symbol "public: virtual 
void __cdecl pcl::RangeImage::getHalfImage(class pcl::RangeImage 
&)const " (?getHalfImage@RangeImage@pcl@@UEBAXAEAV12@@Z) 

Error   83  error LNK2001: unresolved external symbol "protected: static 
int const pcl::RangeImage::lookup_table_size" 
(?lookup_table_size@RangeImage@pcl@@1HB) 

Error   86  error LNK2001: unresolved external symbol "protected: static 
class std::vector<float,class std::allocator<float> > 
pcl::RangeImage::cos_lookup_table" 
(?cos_lookup_table@RangeImage@pcl@@1V?$vector@MV?$allocator@M@std@@@std@@A) 

Error   87  error LNK1120: 10 unresolved externals 

I found a similar problem reported at this post
http://www.pcl-users.org/FW-Link-time-errors-in-RangeImage-with-clr-td3581422.html
but that post is from 2011 and pcl version 1.3.0. Apparently it was solve in version 1.4.0 but I have a similar problem now with pcl version 1.6.0.

Is there a way to fix this? I'm I doing something wrong? Please, help me.

thank you for take a time to read mi question.

@taketwo
Copy link
Member

taketwo commented Jul 21, 2014

I would suggest you to try compiling the library from the latest source. Then try to apply the fixes proposed in that thread.

@anshulvj
Copy link

anshulvj commented Apr 3, 2018

I have a similar issue. I am using Visual Studio 2017 (v14) 64-bit on Win 10 64-bit. PCl 1.8 works fine on all other projects where I am using it (on Visual Studio 2013, 2017 is a recent upgrade). When I try to use RangeImage Class I get the following errors:

Error LNK1120 6 unresolved externals IRS2PlaneFitting F:\IntelRealsenseDataAQ\ProcessIntelRealsense2Data\x64\Release\IRS2PlaneFitting.exe 1 Error LNK2001 unresolved external symbol "protected: static class std::vector<float,class std::allocator<float> > pcl::RangeImage::asin_lookup_table" (?asin_lookup_table@RangeImage@pcl@@1V?$vector@MV?$allocator@M@std@@@std@@A) IRS2PlaneFitting
F:\IntelRealsenseDataAQ\ProcessIntelRealsense2Data\IRS2PlaneFitting\IRS2PlaneFitting.obj 1 Error LNK2001 unresolved external symbol "protected: static class std::vector<float,class std::allocator<float> > pcl::RangeImage::atan_lookup_table" (?atan_lookup_table@RangeImage@pcl@@1V?$vector@MV?$allocator@M@std@@@std@@A) IRS2PlaneFitting

F:\IntelRealsenseDataAQ\ProcessIntelRealsense2Data\IRS2PlaneFitting\IRS2PlaneFitting.obj 1 Error LNK2001 unresolved external symbol "protected: static class std::vector<float,class std::allocator<float> > pcl::RangeImage::cos_lookup_table" (?cos_lookup_table@RangeImage@pcl@@1V?$vector@MV?$allocator@M@std@@@std@@A) IRS2PlaneFitting

F:\IntelRealsenseDataAQ\ProcessIntelRealsense2Data\IRS2PlaneFitting\IRS2PlaneFitting.obj 1 Error LNK2001 unresolved external symbol "protected: static int const pcl::RangeImage::lookup_table_size" (?lookup_table_size@RangeImage@pcl@@1HB) IRS2PlaneFitting

F:\IntelRealsenseDataAQ\ProcessIntelRealsense2Data\IRS2PlaneFitting\IRS2PlaneFitting.obj 1 Error LNK2001 unresolved external symbol "public: virtual void __cdecl pcl::RangeImage::getHalfImage(class pcl::RangeImage &)const " (?getHalfImage@RangeImage@pcl@@UEBAXAEAV12@@Z) IRS2PlaneFitting

F:\IntelRealsenseDataAQ\ProcessIntelRealsense2Data\IRS2PlaneFitting\IRS2PlaneFitting.obj 1 Error LNK2001 unresolved external symbol "public: virtual void __cdecl pcl::RangeImage::getSubImage(int,int,int,int,int,class pcl::RangeImage &)const " (?getSubImage@RangeImage@pcl@@UEBAXHHHHHAEAV12@@Z) IRS2PlaneFitting

F:\IntelRealsenseDataAQ\ProcessIntelRealsense2Data\IRS2PlaneFitting\IRS2PlaneFitting.obj 1 Error (active) E1256 __w64 can only be specified on int, long, and pointer types IRS2PlaneFitting c:\wxWidgets-3.1.0_vs2017build\include\wx\defs.h 1283

I read everything I could about this error on PCL mailing list but could not find a solution link which says this bug should not be present in the latest versions. I am using 1.8. Any thoughts? If there is an easier fix than recompiling the whole pcl and dependencies and the works, that is better for me.

Thanks in advance.

@patrickabadi
Copy link

I had the same issue and was able to work around it. It's really strange but here's what I found:

If I returned the RangeImage through a local function I would get linker errors:

pcl::RangeImagePlanar ConvertToRangeImage (const PointCloudXYZRGBPtr & input)
{
  pcl::RangeImagePlanar rangeImage;

  return rangeImage;
}

If I just worked with the RangeImage inside a function I no longer received these linker errors:

KeypointIndicesT PclUtilities::DetectKeypoints ( const PointCloudXYZRGBPtr & input )
{
  KeypointIndicesT keypoints;

  pcl::RangeImagePlanar rangeImage;

  return keypoints;
}

Sadly, I'm not sure why it works but I hope this helps.

@stale
Copy link

stale bot commented May 19, 2020

Marking this as stale due to 30 days of inactivity. It will be closed in 7 days if no further activity occurs.

@stale stale bot added the status: stale label May 19, 2020
@kunaltyagi
Copy link
Member

@PointCloudLibrary/testers-windows

@stale stale bot removed the status: stale label May 19, 2020
@kunaltyagi kunaltyagi added needs: testing Specify why not closed/merged yet kind: compile error Type of issue platform: windows labels May 19, 2020
@kunaltyagi kunaltyagi changed the title error linking pcl rangeimage LNK2020 LNK2001 LNK1120 [windows] error linking pcl rangeimage LNK2020 LNK2001 LNK1120 May 19, 2020
@oliteksamuelfogarty
Copy link

I'm experiencing the same problem - and like patrickabadi find this only happens if the RangeImagePlanar is being returned by a function.

@AlexJOJO-ray
Copy link

AlexJOJO-ray commented Oct 20, 2023

I have the some problem with vs2019 and PCL 1.11.1 when using the Common Language Runtime Support (/clr).
I didn't use RangeImage Class, however, I got the similar error:
**
LNK2001 unresolved external symbol "protected: static class std::vector<float,class std::allocator > pcl::RangeImage::asin_lookup_table" (?asin_lookup_table@RangeImage@pcl@@1v?$vector@MV?$allocator@M@std@@@std@@A)
LNK2001 unresolved external symbol "protected: static class std::vector<float,class std::allocator > pcl::RangeImage::atan_lookup_table" (?atan_lookup_table@RangeImage@pcl@@1v?$vector@MV?$allocator@M@std@@@std@@A)
LNK2001 unresolved external symbol "protected: static class std::vector<float,class std::allocator > pcl::RangeImage::cos_lookup_table" (?cos_lookup_table@RangeImage@pcl@@1v?$vector@MV?$allocator@M@std@@@std@@A)
**
Are there some solutions? Thank you in advance!

@windwang
Copy link

windwang commented Jul 5, 2024

same problem with vs2022 and PCL 1.14.1 when using the Common Language Runtime Support (/clr).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: compile error Type of issue needs: testing Specify why not closed/merged yet platform: windows
Projects
None yet
Development

No branches or pull requests

8 participants