-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
MSVC linker error json_c_strerror #347
Comments
i test the file of test_util_file is error! |
you need add "strerror_override.c" file to vs project. |
Just an empty file to https://github.com/json-c/json-c? |
Thank you for alexukr! I disregarded it(extern int _json_c_strerror_enable = 0;) in( test_util_file.cpp).i don't know ,What's the role of ' _json_c_strerror_enable' .and i have a waring. for _json_c_strerror.c:\program files (x86)\microsoft visual studio 9.0\vc\include\string.h(126) : warning C4985: “_json_c_strerror”. I've added it(#define _CRT_SECURE_NO_WARNINGS) and strerror_override.c |
The files json-c.vcproj, json-c.vcxproj and json-c.vcxproj.filters are out of date with respect to their lists of source files and headers. While presumably I could just hand edit those, it would probably be better for someone with a Windows build environment to add the files to the VS project, as @Haffon suggested. |
I actually don't use json-c.vcproj, json-c.vcxproj and json-c.vcxproj.filters. For my project I have my own cmake file to produce my Visual Studio project files with the settings I need. So the problem was in my cmake file - it didn't add new files (strerror_override.h and strerror_override.c) to the project. After I added them my problem was solved. So the ticket can be closed. |
hmm... we have strerror_override.c in CMakeLists.txt, but not strerror_override.h. Did you just add it to the set(JSON_C_HEADERS ...) section ? |
I have my own CMakeLists.txt (probably, because there was no CMakeLists.txt in your repo when I started using it). But, regarding your question on JSON_C_HEADERS, you can say so, effectively what I did is I added strerror_override.c to JSON_C_SOURCES and it started to work for me. But just for completeness I added strerror_override.h to my JSON_C_HEADERS as well. |
I forked this repository and committed so they can be compiled by vs2010. you can download special files you need from it, but don't merge them, as I changed the API. Don't add .vcxproj or .vcxproj.filters to json-c source, as they can be generated by CMake, but I don't know cmake is owner recommend toolchain. Any way, cmake works by change CMakeLists.txt a lit. |
Thank you for @alexukr , //****I modify the file of json_inttypes.h #include "json_config.h" #if defined(_MSC_VER) && _MSC_VER <= 1700 #define PRId64 "I64d" #if defined(WIN32) && !defined(__cplusplus) #else #ifdef JSON_C_HAVE_INTTYPES_H #endif #endif
3.can you tell me what the function is correct? Or tell me how to make/link the project in win32. |
If VS2008 is missing so many things, why keep using it? The changes to make it work in VS2010 look fairly minimal, so I'm inclined to say that VS2008 is simply not supported. Anyway, that's separate from the immediate issue described here. @Haffon, you said "cmake works by change CMakeLists.txt a lit." What needs to be changed? If that can be fixed, then we'll just drop the checked-in vxproj files. |
@hawicz I see. I will change back the API and spin another pull request. In fact the strerror_override.c should conditional include to project by STRERROR_OVERRIDE_IMPL macro, it seem's not defined in default, so the strerror_override.c file should include to project by default. The conclusion is: we should keep update the cmake script to reflect this logical, but I'm new guy to cmake, give me some time if no other updating it. |
Thanks for everyone! I can learn lots of knowledge. |
No, strerror_override.c should always be included, it is NOT conditional. The STRERROR_OVERRIDE_IMPL define is so the code in strerror_override.c can be compiled without the "strerror" symbol being renamed, otherwise _json_c_strerror() would end up calling itself in an infinite loop. |
With the changes from PR#359, and the removal of the old project files in commit e1561ed, I think this issue can be closed. |
This is probably related to #336
I link my cross-platform program (Linux/Mac/Windows) with json-c.
Today I updated and rebuilt json-c from master. Mac and Linux builds are ok, on Windows I get the following error:
error LNK2019: unresolved external symbol __json_c_strerror referenced in function __json_object_to_fd
The json-c library itself has been built successfully, but my program that links with it fails to be built now.
Using MSVC 14 (2015), 32-bit build, both Debug and Release fail.
I rolled back to this commit: c0b7d76, rebuilt json-c and after that I was able to link my program with it successfully.
The text was updated successfully, but these errors were encountered: