Visual Studio External Symbol Error while file is present - c++

I am trying to compile minidump_file_writer_unittests located here to compile on my Windows machine. You can clone the repository to download the solution. The code previously was only compiled for Linux so there are some problems. Currently, I am facing Unresolved External Symbol error. I understand that this error is because my code can't find the relevant source files.
Concretely, the basic problem is that minidump_file_writer.cc fails to locate the function UTF32ToUTF16Char(*str, out) on line 122 and UTF8ToUTF16Char on line 151. This function is present in ..\common\string_conversion.h and the source file for this header file is in the same directory. I have included the source in the project and yet it fails to detect the problem.
Can you please see where exactly is the problem here?

You need to include file convert_UTF.c to your "minidump_file_writer_unittest" project. It compiles after that.

Related

Resolving and understanding external symbol errors in Visual Studio (C++)

Very new to C++ and the VS IDE, and I'm trying to start working with Dear imGUI and openGL with a hello world function. I've added resources with lib and dll files before for c++ (for openGL), but not something like imGUI which only has .h and .cpp files - feels like I'm struggling to understand how to inform VS of where those are and how they link up.
Here's an example of an error I saw when building:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol _glfwGetWindowSize referenced in function "void __cdecl ImGui_ImplGlfw_NewFrame(void)" (?ImGui_ImplGlfw_NewFrame##YAXXZ) imGUITrial1 ..\Coding\imGUITrial1\imgui_impl_glfw.obj 1
So I opened up imgui_impl_glfw and found the function, and it appears to reference a function declared in glfw3.h...but that function looks like just a declaration, with no definition. I had previously added each folder with these files in it to the project additional directories, so I went ahead and added glfw3.h as a resource to my sources folder in the solution as well. That didn't change anything, so now I'm not sure how to find where the function is actually defined, or if the issue is that I need to somehow tell VS that this file exists in a another nested properties window?
Maybe it will help to have a screenshot of the solution. These are largely files copied from the github that I haven't changed (which I chose from looking through the backend examples), so I don't think I broke anything in the files themselves.
enter image description here

Debugging compiler failure

I'm trying to compile an Arduino/C++ program for an ESP8266 and am running into a strange error that I cannot resolve. I am using MS Visual Studio Code, and even though I have the path to the header file for the Adafruit MQTT library in my includePath section of the c_cpp_properties.json file, when I try to compile the my source, I get the following in the output:
src\main.cpp:3:27: fatal error: Adafruit_MQTT.h: No such file or directory
#include "Adafruit_MQTT.h"
^ compilation terminated.
*** [.pioenvs\esp12e\src\main.o] Error 1
What's odd is that if I right-click on the include statement for the header, and click Goto Definition, the library code is indeed pulled up.
This makes me think that the IDE can find the file but the compiler cannot. Unfortunately I haven't used MS-VSC before so not sure why this might be happening.
Does anyone with more experience in this know where I should focus my attention?
Thanks for any and all help.
Does the program compile if you place the header file "Adafruit_MQTT.h" in the same directory as your main.cpp?
Using the quotes around the name of the header file makes the compiler look for the file in the same directory as the including file.

GLES-Render.cpp cocos2d-X causing compile time errors

I have copied the GLES-Render.h and GLES-Render.cpp files into my project and added them to the Android.ml file. Now the file is full of errors like
Symbol 'GL_FLOAT' could not be resolved
Symbol 'GL_FALSE' could not be resolved
When i click on any of these symbols eclipse opens up glew.h file or the some error open up on CCGLProgram.h. What am i doing wrong ? Is there OpenGL includes that i have to include ?
Kind Regards
You cna check this GLES-Render.h/.cpp in this link. and also add GLES-Render in your android.mk file. GLES-RENDER

Link mysql_library_end()

I've been trying to resolve a serious memory leak in my C++ application. I've narrowed it down to the creation of MySQL connections and the mysqlpp doc (plus lots of googling) indicates that I need to call mysql_library_end() to tell the C API to clean up after itself.
When I try to use this function, Visual Studio throws a Link error for "mysql_library_end()". Fair enough, I didn't tell it where to look.
When I include the header file mysql.h and rebuild, Visual Studio then throws a Link error for "mysql_server_end()" instead. I checked mysql.h (in my build environment) and the only reference to the function I want to use ( mysql_library_end() ) is:
#define mysql_library_end mysql_server_end
There is a function declaration for mysql_server_end() in the file but Visual Studio can't seem to see it. I'm just stuck with this Linker error and I have no idea why it is happening.
Can anyone help?
Cheers,
Adam.
EDIT
I'm using Visual Studio 2005.Error message from the IDE is:
Error 6 error LNK2019: unresolved external symbol _mysql_server_end#0 referenced in function "public: __thiscall CConnectionParams::~CConnectionParams(void)" (??1CConnectionParams##QAE#XZ) CConnectionParams.obj
Where CConnectionParams is the .cpp file of the call to mysql_library_end().
Found the solution. The header file on it's own isn't enough, the whole library needs to be linked in. There are two libraries that can be used to interface the MySQL C API: libmysql.lib and mysqlclient.lib. One is static, one is dynamic. The one that worked for me was libmysql.lib. Note that I therefore didn't need to #include mysql.h as a result.
To link this library in Visual studio you just need to include it as part of your project dependencies. I dragged it into the solution tree from it's directory, the mysql install, but this is not a very elegant method because it only works for VS and not other build environments.

Creating and linking against a .lib file generated from an old DLL file

I have inherited an old VC++ project that requires an old proprietary .lib file to link against. I have the header file for the lib, but the original developers seem to have lost the .lib file.
I did find a DLL file that I believe a driver from this software package uses that has the same name as the .lib and .h file. I followed these instructions: http://adrianhenke.wordpress.com/2008/12/05/create-lib-file-from-dll/
With that, I was able to generate a .lib file that as far as I know, contains the exact same functions as the .h file I have (the intermediate DEF file shows this). The first project was able to build and link against it successfully, but a second project I have that makes use of the library built by the first project fails to link complaining about unresolved symbols for the functions in the DLL I'm trying to use:
error LNK2019: unresolved external symbol _ncb_receive_wait#12 referenced in function "public: int __thiscall PLC::Write(unsigned short,void *,unsigned short)" (?Write#PLC##QAEHGPAXG#Z)
I'm trying to understand if this is even possible to do? (Grab an old DLL file, generate a lib from it, link against it and use the DLL file?)
I know that this answer is too late for the original question, but hopefully it might help others with a similar problem googling for a solution:
I had a similiar problem linking to an old DLL from Visual C++. I also went down the route of creating a def file and then creating a new lib file from this def file. Then to resolve a linkage error with Visual C++ trying to link to a mangled function name, I manually edited the EXPORTS section of the def file to create a function name alias, along the lines of:
_ncb_receive_wait#12 = ncb_receive_wait
You can try a more automated approach as suggested by MingW to avoid missing a function or other typos.
Otherwise, perhaps the header and binary are incompatible.