Closed fschramka closed 7 years ago
doesnt work with vs2012 if I just declare and define it in the header file.
@filipschramka What error do you get? I mean if all you do is delete the line:
const DecodeHintType DecodeHints::CHARACTER_SET;
in DecodeHints.cpp.
Leave everything else untouched from master.
So DecodeHints::CHARACTER_SET will still be defined and declared in the header.
Fehler 1 error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""public: static unsigned int const zxing::DecodeHints::CHARACTER_SET" (?CHARACTER_SET@DecodeHints@zxing@@2IB)" in Funktion ""public: static class std::basic_string<char,struct std::char_traits
Sorry that it is in german^^ but it works fine, if you use my solution above :)
Yeah, my German is pretty rusty, but Google translate to the rescue.
The point is you don't need all those changes. All you need to do is delete one single line, that's it. The value will still be declared and defined in the header, then you won't get any errors at all. I'm guessing the reason you got the error above about the unresolved symbol is because you deleted the line from the .cpp file but also deleted the definition in the header. Please do:
git remote add upstream https://github.com/glassechidna/zxing-cpp.git
git fetch upstream
git reset --hard upstream/master
Then go and delete the one line (in DecodeHints.cpp):
const DecodeHintType DecodeHints::CHARACTER_SET;
Then:
git add --update
git commit -m "Deleted duplicate CHARACTER_SET declaration"
git push -f origin master
no I did not delete the definition in the header file...
Hmm, I'm very confused. I just downloaded Visual Studio 2012 Express in a Windows 8.1 VM and compiled without any changes required.
well thats the point, you can compile it without any changes. But if you create a new project and use the generated library, it won't work. Because you have multiple definitions, in your own file, where you include the DecodeHints.h file and inside the library.
Sorry, to be clear, the whole solution builds fine. Both libzxing, but more importantly the zxing executable, which links to, and includes the headers for, libzxing exactly the same way your project should be using it. I even manually changed the compilation mode to be static (it's DLL by default), and didn't see any problems.
Hmm yeah the solution works fine here as well... I build the whole solution with cmake (got a static lib then after compiling). The only thing I had to change before using zxing in my project was Multithreaded-Debug-DLL (/MDd) to Multithreaded-Debug (/MTd). But this shouldnt make any difference.
I think this is no longer needed, now that the build is passing. Let me know if that's not the case!
You need it somewhere in the project, so I just changed the definition. The last commit was just cause my formatter changed the whole file and the difference wasn't visible at once.
Hope it's alright :)