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

Problem with the linking #33

Open
OM92 opened this issue Jan 10, 2017 · 13 comments · May be fixed by #79
Open

Problem with the linking #33

OM92 opened this issue Jan 10, 2017 · 13 comments · May be fixed by #79

Comments

@OM92
Copy link

OM92 commented Jan 10, 2017

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

@JXLee33
Copy link

JXLee33 commented Mar 30, 2018

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

@vekkuli
Copy link

vekkuli commented Oct 2, 2018

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

@Mikez2015
Copy link

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

@Mikez2015
Copy link

Mikez2015 commented Feb 18, 2020

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:

@JXLee33
Copy link

JXLee33 commented Feb 18, 2020 via email

@Mikez2015
Copy link

Mikez2015 commented Feb 18, 2020

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.

@JXLee33
Copy link

JXLee33 commented Feb 18, 2020 via email

@Mikez2015
Copy link

Mikez2015 commented Feb 18, 2020

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

Latest VS 2019, x64

@JXLee33
Copy link

JXLee33 commented Feb 18, 2020 via email

@Mikez2015
Copy link

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

Where? I do not see the link.

@JXLee33
Copy link

JXLee33 commented Feb 18, 2020 via email

@Mikez2015
Copy link

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"<notifications@github.com> Date: Tue, Feb 18, 2020 19:17 PM To: "danfis/libccd"<libccd@noreply.github.com>; Cc: "Comment"<comment@noreply.github.com>;"JXLee33"<1072324172@qq.com>; 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.

@SpaceIm
Copy link

SpaceIm commented Feb 23, 2020

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.

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

Successfully merging a pull request may close this issue.

5 participants