I've recently decided to try out PostgreSQL as the database platform for some C++ development I'm working on. I decided to use libpqxx as the connection library for my project, and quickly found out this would be an uphill battle to do from VS 2015 on a Windows 10 machine.
After much teeth-gnashing and nail-biting, I have gotten libpqxx to compile on Windows 10.
This leaves me with the following directory structure
Per libpqxx's documentation, I also placed a copy of libpq.dll in my project's executable directory. Please note: I have done this for both debug and release builds, tried to build both, and ended up with the same result.
All the tutorials I've seen seem to indicate that the library can be used after linking it and simply #including pqxx/pqxx, so I set up a small project to do just that. I receive the error:
fatal error C1083: Cannot open include file: 'pqxx/pqxx': No such file or directory
When attempting to build the project. I have also tried this will both debug and release builds, to no avail.
Here is a screenshot of my linker settings.
Does anyone have any suggestions for how I might be able to link and use this library from Visual Studio 2015?
As Sami Kuhmonen pointed out, this was not actually a linker error, but a compiler error. I needed to include an actual header, which Visual Studio needed to be able to find. After adding the correct folder (C:\libpqxx\include in my case) to Visual Studio's "additional include directories" setting under C\C++ -> General per drescherjm's suggestion, the program compiles just fine.
For future reference:
I did also run into unresolved external linker errors after solving the initial issue. This is because you need to make sure to also link to ws2_32.lib and libpq.lib. You also need to copy some other DLL files that libpq also relies on into your libpqxx lib folder. On my system, I believe these were ssleay32.dll, libeay32.dll, and libintl-8.dll. These files reside under the root of the PostgreSQL install. The DLL step is mentioned under libpqxx's INSTALL.txt file, however I believe it stated that the DLLs resided one folder under where I actually found them.
I have also faced same issue. Then I realized that I was building ,my application as a 32bit. I changed the target to x64 and it compiled successfully
Related
I have read many issues regarding and followed each one but nothing seems to work.
I am trying to include the rdkafka library into my project, but every time I run the application I am getting
The program can't start because librdkafka.dll is missing from your computer.
I can clearly see that librdkafka.dll as well as librdkafka.lib exist in the same directory. I have added the include files to the project, and I have also added the librdkafka.lib to the additional directories in the Linker section. The project builds fine but it throws that error at runtime.
Does anyone know how I can solve this issue?
When in Visual Studio by default it is searching for dlls in the project directory and running the application on its own will try to find the dlls in the current working directory. Moving the dlls to this location seems to solve the issue.
So first I'll say I've looked in a ton of places to no success.
This PDF is where I started:
http://curl.haxx.se/libcurl/c/visual_studio.pdf
It seems outdated and does not include instructions for statically linking libraries. Or at least, I've tried following all of the instructions without any success.
I've tried following answers in
Installing LibCurl on Visual Studio 2010
error LNK2019: unresolved external symbol libcurl Visual studio
Building libcurl library in Visual Studio 2008
and other areas, but have not made any progress.
I will also say that I am NOT a Windows user by any stretch of the imagination. With that said I will lay out what I have done so far.
I am porting over an application I made in a Unix environment, specifically OSX. I've made a lot of progress with the exception of using libcurl. I need to statically link LibCurl so that the executable built by Visual Studio can be moved to other Windows devices as necessary without needing dlls for libcurl or MySQL (which I am also linking statically).
Anyway, with the gracious help of this repository:
https://github.com/blackrosezy/build-libcurl-windows
I was able to build libcurl onto my Windows device. This was a difficult process before I found this repository. Now I have a lib and an include folder. Inside the lib folder there are release and debug folders for dll and static builds each. Inside the static-release folder I have ONLY libcurl_a.lib. Inside the dll-release folder I have libcurl.dll, libcurl.lib, and libcurl.pdb.
I have gotten the program to SUCCESSFULLY build when dynamically linking from the dll-release folder. However, when I try to link statically from the static-release folder, I get 11 or so linker errors.
I have also included "libcurl_a.lib", "wldap32.lib", "ws2_32.lib", "winmm.lib", "libeay32.lib", and "ssleay32.lib" as dependencies.
In addition to all of this, I used NuGet to get libssh2.1.4.3.1, openssl.1.0.1.21, zlib.1.2.8.1 along with redist versions of all of these. I have included the following paths in my library directories as well:
path_to_libssh\build\native\lib\v110\Win32\Release\static\cdecl\<br>
path_to_openssl\build\native\lib\v110\Win32\Release\static\cdecl\<br>
path_to_zlib\build\native\lib\v110\Win32\Release\static\cdecl\<br>
I have also put the /include/ paths from these folders in my list of include directories.
In my preprocesser definitions I have "CURL_STATICLIB".
However, despite all of these steps that I have taken from multiple sources including some great answers on this site, and the PDFs and some answers on the LibCurl site, I am still having these linker errors.
As an example, one of the errors that I feel is slightly indicative (sorry I cannot copy and paste all of these errors from VS2013 that I can tell) says:
"error LNK2019: unresolved external symbol curl_easy_setopt referenced
in function 'public:__cdecl Curler::Curler(char*)'(??0Curler##QEAA#PEAD#Z)"
All of these errors are laid out similarly, pointing to some sort of __cdecl Curler function, with the error code LNK2019.
Anyway, my question is basically: what am I doing wrong? I am sorry if this is a vague question, or if you feel as though this is a repeat. But I can assure you that I have looked at a large list of Stack Overflow questions and other areas of the internet with no success, and I've begun to feel very lost. Things that seem to work for so many others I just cannot get to work. I think a large portion of the problem is my newness to Windows. If there is any other information that I can provide in order to help you help me, then I will gladly provide it. I really appreciate any help you can give me. Thanks.
First of all, thank you to user Pawan who edited my post; it was my first post and he helped make it up to standards aesthetically with the community so I know what to do in the future.
Anyway, I think I solved my problem. It's probably a bit of an edge case, but it worked for me anyway.
After a while, I decided to build libcurl for Win64 using Visual Studio. To do this, I grabbed the code from this helpful repository:
https://github.com/bagder/curl
I cloned it, and navigated to that directory. I then ran the following commands (this is in Powershell so I used unix-esque commands, but I did not use MinGW for this):
mkdir build
cd build
cmake .. -G "Visual Studio 12 2013 Win64"
This built a Visual Studio Solution that I could open in Visual Studio 2013. In Visual Studio, I went to
Project Properties -> C/C++ -> Code Generation
And switched the Runtime Library option to "Multi-threaded (/MT)"
Then I built the project, which outputted the following files in the following path:
path_to_pulled_code\build\lib\Release\libcurl.dll
path_to_pulled_code\build\lib\Release\libcurl_imp.exp
path_to_pulled_code\build\lib\Release\libcurl_imp.lib
So, now I had the lib file I needed. Now, in:
Project Properties -> Linker -> Input
I put "libcurl_imp.lib" and "ws2_32.lib" under Additional Dependencies.
As I've said before, I made sure that I had "CURL_STATICLIB" in Preprocessor Definitions. I also switched Runtime Library to "Multi-threaded (/MT)" for this project.
After all that, well, it compiled! For some reason I needed to copy libcurl.dll that the aforementioned Visual Studio build of bagder's repo made into my executable path in order for the solution to actually work. But it seems to be working now at least!
Thanks guys. Hopefully this answer will help anyone else who stumbles onto this problem like I did.
I'm having a lot of trouble linking my project with FreeImage library with VSE 2013
I've followed this answer for VS2010 to no avail: Linking FreeImage as a static library in VS2010?
I am getting LNK2019 errors when calling FreeImage functions.
I've linked the library just as I would any library. Below are the following steps I made:
Download FreeImage Source.
Open the 2008 Solution (converted to 2013) and changed Code Generation to /MDd for all projects
Attempted to build project but for some reason min/max functions were not defined So I included algorithm.h to those files and that stopped those errors.
Attempted to build project and I get an error: "Could not open "afxres.h". So I swapped afxres.h with windows.h as suggested in another topic.
Built the project -> success
Copied Fresh FreeImaged.lib to to my project
Added directory to "Additional Library Directories"
Added FreeImaged.lib to Additional Dependencies under linker
Copied FreeImaged.dll to my debug folder where the .exe is being built
Added FreeImage.h to the project
Added #define FREEIMAGE_LIB before including the header
Attempted to build my project -> LNK2019s everywhere.
If anyone has been able to build FreeImage on VS2013 and could share how they did it I would greatly appreciate it, or if anyone has any suggestions.
The reason for your troubles is that with Visual Studio 2013 some breaking changes (as outlined by Microsoft) were introduced in related to C++11 conformity.
One includes that in order to use std::min()/std::max(), you now have to include the header . This also concerns FreeImage. Unfortunately, up until version 3.6.1 (the most recent as of today) this hasn't been fixed yet.
This blog post explains what you need to do to get it to compile. The most relevant part is:
Specifically, you will need to add
include <algorithm>
to the following files:
Source/OpenEXR/IlmImf/ImfOutputFile.cpp
Source/OpenEXR/IlmImf/ImfScanLineInputFile.cpp
Source/OpenEXR/IlmImf/ImfTiledMisc.cpp
Source/OpenEXR/IlmImf/ImfTiledOutputFile.cpp
Source/OpenEXR/Imath/ImathMatrixAlgo.cpp
I was able to get this to work by going into the Configuration Manager unchecking FreeImage and checking FreeImageLib under build. Also disabling whole program optimization seems to make the binary size more normal and, gets rid of warnings when linking.
I know this question is over a year old. Just providing an answer to anyone google searching this problem like me.
version: FreeImage3170Win32Win64.zip
os.env.: win7 64bit visualstudio ULTIMATE 2013
operation:
1_ just unpacking the zip somewhere
e.g. (D:/library/FreeImage3170Win32Win64/FreeImage)
2_ in C/C++->General->Additional Including Directerories
add (D:/library/FreeImage3170Win32Win64/FreeImage/Dist/x32)
3_ in Linker->General->Additional Library Directerories
add (D:/library/FreeImage3170Win32Win64/FreeImage/Dist/x32)
4_ in Linker->Input->Additional Dependency
add (FreeImage.lib)
PS0: i just add a new entry to Include Directories and Library
Directories and FreeImage.lib to Linker->input in Visual Studio without rebuild the FreeImage library
:)
PS1: error LNK2019 occured when i added the FreeImage/Dist/x64 option
;( ( got no idea about this)
maybe this helps :)
I've been trying to compile tulip using cmake to generate visual studio 2012 project files. It's giving me lots of trouble. I don't know how to get this to build. I've been trying to get visual studio to build this for 4 days now, and I'm extremely frustrated. Essentially, I follow the steps here, and then set the variables CMAKE_LIBRARY_PATH AND CMAKE_INCLUDE_PATH according to these instructions.
To get to where I'm at, all you have to do is download tulip, and:
Unzip it, create a separate build directory outside of this source directory
Open CMake-gui to the source and build directories
Hit configure. Check use qt5, tell it where qmake is (make sure it's qt5)
You need some dependencies as described in The Independent CMake tutorial. Grab all those dependencies
As you continue to hit configure, specify each of the directories that it asks for as it errors out. It should ask for freetype, glew, zlib and sphinx. It shouldn't ask for where libxml or libpng, or libjpeg are. I don't know why it doesn't ask for those.
Generate, and then browse to the ALL_BUILD that you've generated. Open it with visual studio
try to build it with visual studio.
In those instructions and in the process of getting CMake to generate the visual studio build files, it specifically asks for freetype's location. But in my build, it doesn't have a clue how to link the freetype library.
Here are the errors that I get
Here is my CMakeCached.txt
I know that many people aren't going to want to exactly try and go about replicating the build environment, so I've uploaded my build directory to dropbox. You can pull the entire thing down, and then open it in cmake gui and open the visual studio files in there too.
https://www.dropbox.com/sh/qsvukh9t5gb6bvt/tOfOBxWgd0
The linker errors you point to (mostly "unresolved external" errors) indicate that there are missing libraries on the link command line.
That is most likely happening because target_link_libraries calls in the tulip project are either being skipped or being called with library names that do not match the library names on disk.
Open up the solution in Visual Studio and right click the project and choose "Properties" -- look at the "Linker > Input" panel at the "Additional Dependencies" field. That should list all the libraries it wants to link to. Is there a freetype library listed there? Does that library exist in the referenced location on your disk?
There could be a mistake in the tulip project, or there could just be something wrong with your build/install of freetype...
UPDATE AFTER SOME CHAT:
Or it may be that you have some libraries built for x86 and some for x64... or maybe some for Debug and some for Release... or maybe even some with the MinGW compiler and some with the Visual Studio compiler. If that's the case, start over, from a clean slate, and build everything with a consistent compiler, configuration type and architecture. Then report back again with an update and see if the problems still remain.
I do with Dave,
You should try to fix your error 1 by 1.
The first error seems to be a link error:
Error 1 error LNK2019: unresolved external symbol gzread referenced in function "public: virtual int __cdecl gzstreambuf::underflow(void)" (?underflow#gzstreambuf##UEAAHXZ) C:\Users\kenne_000\tulip-build\tulip-build-debug\thirdparty\gzstream\gzstream.obj gzstream
gzstream is a third party lib included with tulip source in:
thirdparty\gzstream
from
thirdparty\gzstream\CMakeLists.txt
you can see that the missing symbols should be coming from ZLIB.
However your CMakeCache.txt indicate that
ZLIB_LIBRARY:FILEPATH=C:/Users/kenne_000/dependencies/zlib128-dll/lib/zdll.lib
is found.
So the question may be, was this dependency compiled with the same compiler?
Don't you have compiler-specific name mangling issue ?
I've recently downloaded Assimp and I've run into some troubles.
I've linked the libraries and I can get the program to compile and it runs fine in Release mode; however, the Debug .exe hits me with this error:
The application was unable to start correctly (0xc0150002). Click OK to close the application.
Some more details:
I'm using VS2010 with Target Machine set to x86.
I am using the 32bit debug dll (Assimp32d.dll) that was provided, and I've tried setting runtime libraries to /MT, /MTd, /MD, and /MDd with no luck.
I read from other similar threads that I should run Dependency Walker on the .exe, but I'm not sure what the output means. I'll paste it here if this helps you guys.
Error: The Side-by-Side configuration information for "c:\users\-----\documents\visual studio 2010\projects\AssimpTest\debug\ASSIMP32D.DLL" contains errors. The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail (14001).
Error: At least one required implicit or forwarded dependency was not found.
Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module.
Error: Modules with different CPU types were found.
Rather than rebuilding the libraries, I downloaded a different set of libraries (it was the SDK installer) and the debug dll's from that are working perfectly.
Just in case anyone has the same problem with the same software, this was the exact name of the installer that worked for me: assimp-sdk-3.0-setup.exe
I ran into the same problem when trying to run a 64-bit project in Debug mode when using Assimp 3.0.
What I did was go to assimp/workspaces/vc9, open assimp.sln in Visual Studio 10, convert the project, then rebuild the 32 and 64-bit dll.
Mind you, you've got to install boost for that as well, and edit the project properties so it points to the boost directory for includes.
There's probably a way to do it using CMake as well, but I found the whole process too cumbersome to bother with in the first place.
My solution was just to link the debug build to the release .dll files. No more issues, and I wasn't that interested in debugging the Assimp library anyway!
I faced the same issue, later on I downloaded the "assimp-sdk-3.0-setup.exe" file & installed it as a standard windows application.
I pointed Visual Studio Solution Include & Lib directories to respective folders from newly installed location, copied DLL to my application location. The problem was resolved. Hope this helps someone.
Cheers.