Of v0.11.2 Error LNK2038

When I compile the sources with the addons, it will create a addons folder in the project. And then I change the Debug or Release mode to run it, will occur the LNK2038 error. But the of v0.11.0 not create the addons folder. How could I fix the issue?


Hi @wangwenfeng, that’s a linker error and it means that your project hasn’t been setup properly. May I ask how you created your folder? Try to use the openframeworks addons plugin that comes with Visual Studio 2017 to include add ons in your project :slight_smile:

Hi!!

Do the regular examples that come with OF work for you?
If they don’t either, then it might be an issue with either:

  1. Not having all the components required in VS 2017 ( see: https://openframeworks.cc/setup/vs/ )
  2. It could be your file path having special characters where OF is located. ( sometimes non english characters in the filepath break OF compile/linking ).

I hope that helps!
Theo

I try to compile the regular example that guiExample, it output the same addons folder. I have checked the path, it doesn’t have non english characters, my vs version is Microsoft Visual Studio Professional 2017 15.9.34.


image

I use the projectGenerator-vs to create the project, I have compared the difference of ofv0.11.0 and ofv0.11.2 project’s source file. I find the .vcxproj have some different lines. The ofv0.11.0 is $(IntDir), and the ofv0.11.2 is $(IntDir)%(RelativeDir), I think the RelativeDir is the reason to create the addons folder. I reset the option in vs, the addons is disappeared. So change the scripts/templates/vs/emptyExample.vcxproj may fix the issue.
image
line number: 106, 128, 149, 172

Hey,

Glad you tracked it down!

That is weird, though as I’ve been using 0.11.1 with VS 2017 for a project and haven’t seen this issue.
I’ll try the guiExample though and see if it happens for me.

The Github fix was meant to create a nested folder structure inside of obj/ so that classes with the same file name didn’t overwrite each other. I wonder if the …/…/…/addons/ is popping it out of the obj/ folder.

Again though I didn’t see this on VS 2017 Community addition.

Hmmm…

@wangwenfeng

Okay I get the same issues here when I switch from Debug to Release.
I think because of the …/…/…/addons/ relative path the addons/ obj folder is placed out of the main obj/ folder and then is not recompiled when switching from Debug to Release (or vice versa ).

Definitely a bug and might warrant a patch-release :man_facepalming:

Changing:
$(IntDir)%(RelativeDir)

to:
$(IntDir)%(Directory)

Should fix it and still preserve the fix of not breaking linking when two files have the same name. But it does create the full path inside the obj folder. ie: obj/x64/Release/Users/Me/Documents/Code/of_0.11.2/addons/src/ofxGui.o

I’ll see if there is a better fix though where we could maybe just take the parent folder or something.

Thanks for reporting this issue and tracking it down!
Theo

1 Like