libccd icon indicating copy to clipboard operation
libccd copied to clipboard

Problem with the linking

Open OM92 opened this issue 8 years ago • 13 comments

Hello, first of all, I want to say a big thank you to danfis for the library. I am completely new to the library and want to start to use it. I already installed it and I am trying to compile the example GJK - Intersection Test. However, I am encountering a linking problem with the lines: CCD_INIT(&ccd); // initialize ccd_t struct int intersect = ccdGJKIntersect(obj1, obj2, &ccd); in the main function and the compiler is giving me the following error messages: undefined reference to _imp__ccdFirstDirDefault' undefined reference to _imp__ccdGJKIntersect'

I did add the library libccd in my compiler so I don't understand why the compiler can't find those functions. My questions may be trivial and maybe it is not right place to post it, but I couldn't find any help anywhere else.

I am using windows 7 and Mingw Any help would be much appreciated. Thank you in advance

OM92 avatar Jan 10 '17 14:01 OM92

I have the same problem. You can try to add extern int ccdGJKIntersect(const void *obj1, const void *obj2, const ccd_t *ccd) before main() function. And if you find red line under CCD_INIT,you can try this https://github.com/danfis/libccd/pull/40/files

JXLee33 avatar Mar 30 '18 13:03 JXLee33

I had similar linking issues. I had set the library to be built static in cmake but it seemed like the CCD_EXPORT definition wasn't right. Is the CCD_STATIC_DEFINE defined properly? Anyway, I was able to resolve the issue by overriding the ccd_export.h with

#ifndef CCD_EXPORT_H
#define CCD_EXPORT_H

#define CCD_EXPORT

#endif

vekkuli avatar Oct 02 '18 08:10 vekkuli

Have same problem - fatal error LNK1120. I tried to do as advised vekkuli, but it did not help.

Mikez2015 avatar Feb 18 '20 07:02 Mikez2015

I have the same problem. You can try to add extern int ccdGJKIntersect(const void *obj1, const void *obj2, const ccd_t *ccd) before main() function.

warning C4273: ccdGJKIntersect:

Mikez2015 avatar Feb 18 '20 07:02 Mikez2015

Warning means you can run it but you still have some potential problem. In most situation, it is just a useless hint. It depends on your compiler.

------------------ 原始邮件 ------------------ 发件人: "Mikez2015"<[email protected]>; 发送时间: 2020年2月18日(星期二) 下午3:17 收件人: "danfis/libccd"<[email protected]>; 抄送: "X"<[email protected]>; "Comment"<[email protected]>; 主题: Re: [danfis/libccd] Problem with the linking (#33)

I have the same problem. You can try to add extern int ccdGJKIntersect(const void *obj1, const void *obj2, const ccd_t *ccd) before main() function. And if you find red line under CCD_INIT,you can try this https://github.com/danfis/libccd/pull/40/files

warning C4273: ccdGJKIntersect:

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

JXLee33 avatar Feb 18 '20 07:02 JXLee33

Warning means you can run it but you still have some potential problem. In most situation, it is just a useless hint. It depends on your compiler.

But I still get the error LNK1120. I tried different tips, but nothing helps.

Mikez2015 avatar Feb 18 '20 07:02 Mikez2015

Please tell me your compiler, if you use visual stdio2015, maybe I could give you my test program.

------------------ 原始邮件 ------------------ 发件人: "Mikez2015"<[email protected]>; 发送时间: 2020年2月18日(星期二) 下午3:53 收件人: "danfis/libccd"<[email protected]>; 抄送: "X"<[email protected]>; "Comment"<[email protected]>; 主题: Re: [danfis/libccd] Problem with the linking (#33)

Warning means you can run it but you still have some potential problem. In most situation, it is just a useless hint. It depends on your compiler. … ------------------ 原始邮件 ------------------ 发件人: "Mikez2015"<[email protected]>; 发送时间: 2020年2月18日(星期二) 下午3:17 收件人: "danfis/libccd"<[email protected]>; 抄送: "X"<[email protected]>; "Comment"<[email protected]>; 主题: Re: [danfis/libccd] Problem with the linking (#33) I have the same problem. You can try to add extern int ccdGJKIntersect(const void *obj1, const void *obj2, const ccd_t *ccd) before main() function. And if you find red line under CCD_INIT,you can try this https://github.com/danfis/libccd/pull/40/files warning C4273: ccdGJKIntersect: — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

But I still get the error LNK1120. I tried different tips, but nothing helps.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

JXLee33 avatar Feb 18 '20 08:02 JXLee33

Please tell me your compiler, if you use visual stdio2015, maybe I could give you my test program.

Latest VS 2019, x64

Mikez2015 avatar Feb 18 '20 09:02 Mikez2015

This is a test program for cube, open libccdtest.sln, maybe it works.

------------------ 原始邮件 ------------------ 发件人: "Mikez2015"<[email protected]>; 发送时间: 2020年2月18日(星期二) 下午5:05 收件人: "danfis/libccd"<[email protected]>; 抄送: "X"<[email protected]>;"Comment"<[email protected]>; 主题: Re: [danfis/libccd] Problem with the linking (#33)

Please tell me your compiler, if you use visual stdio2015, maybe I could give you my test program. Latest VS 2019, x64

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

JXLee33 avatar Feb 18 '20 10:02 JXLee33

This is a test program for cube, open libccdtest.sln, maybe it works.

Where? I do not see the link.

Mikez2015 avatar Feb 18 '20 11:02 Mikez2015

At first, I used the link as I said in the comment.But then I found that it is more convenient to put some files directly into the project.I couldn't find the original version.Sorry.😐

---Original--- From: "Mikez2015"<[email protected]> Date: Tue, Feb 18, 2020 19:17 PM To: "danfis/libccd"<[email protected]>; Cc: "Comment"<[email protected]>;"JXLee33"<[email protected]>; Subject: Re: [danfis/libccd] Problem with the linking (#33)

This is a test program for cube, open libccdtest.sln, maybe it works.

Where? I do not see the link.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

JXLee33 avatar Feb 18 '20 11:02 JXLee33

At first, I used the link as I said in the comment.But then I found that it is more convenient to put some files directly into the project.I couldn't find the original version.Sorry.😐 ---Original--- From: "Mikez2015"<[email protected]> Date: Tue, Feb 18, 2020 19:17 PM To: "danfis/libccd"<[email protected]>; Cc: "Comment"<[email protected]>;"JXLee33"<[email protected]>; Subject: Re: [danfis/libccd] Problem with the linking (#33) This is a test program for cube, open libccdtest.sln, maybe it works. Where? I do not see the link. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

No problems, thx.

I found sulution: Add "#define CCD_STATIC_DEFINE" to "config.h" and copy to includes. It's work for me.

Mikez2015 avatar Feb 19 '20 08:02 Mikez2015

I've solved linkage errors with msvc like this. If static, CCD_STATIC_DEFINE has to be defined:

  • At libccd compilation time (otherwise it leads to a lot of C4273 warnings "inconsistent dll linkage", and after that it may fail to link into an executable or shared lib).
  • When consuming static libccd.

CMakeLists.txt of libccd could be easily fixed by defining CCD_STATIC_DEFINE not only when CCD_HIDE_ALL_SYMBOLS is ON, but also when BUILD_SHARED_LIBS is OFF.

SpaceIm avatar Feb 23 '20 10:02 SpaceIm