I am trying to access from Visual C++ 2010 Express a Postgres database. I have both on my machine but the SQL calls do not work at all. I have searched many sites. I think that this version of Express does not have any default database connections like the non-express version (especially Visual C++ 2008).
The only thing I could find was the following link and I have following the modifications to the Project Properties area of Visual C++ Express.
http://www.askyb.com/cpp/c-postgresql-example/
When I try to run the C++ code in that website I get errors indicating that it cannot find the functions.
Do you have any ideas of what I am doing wrong? Would it be better for me to use something other than Visual C++ Express 2010 to connect to a postgres db? One of the other Express versions? The regular (non-express) Visual C++?
Thanks
You may also be interested in libpqtypes and libpqxx if you're working with PostgreSQL and libpq. The first provides greatly simplified access to data values from libpq, and the latter provides a more C++-friendly interface.
As for the errors, most likely:
Your include path or link library path is wrong if it's failing at compile-time or link time; or
Your PATH doesn't include libpq, if it's failing at runtime.
Most likely (you didn't provide any actual error messages) the problem is your setup. You need to add the correct header ("include") directory and library directory; if you just copied them from some tutorial, make sure they actually point to the real place where these files (.h and .lib files, respectively) are.
You need do recompile the libpq with MSVC (nmake /f win32.mak all), after that, you need to set your project to use that library, and change the Common Language Runtime Support to (/clr) and not to clr/pure.
Related
I am following a tutorial to use Microsoft SQL Server (I am forced to use this), and the examples use #using , among other, in order to work.
I saw that if I need to configure Visual Studio to support CLR, but then I got different errors I'd like not to debug. Is there a way to make it work without CLR ?
I tried to find these dll in my computer, to add them in the project folder and to add these dependencies in the configuration but it didn't work. Moreover, there are several version of these dll in different folder in the computer (I don't know if I should use one more than another), and there is no lib. At least none I could find.
Thank you for your help
I use Visual Studio 2013 to make a CLR-compatible version of my C++ code library ('mylibrary.lib'). It's been working fine for years, but all of a sudden I'm getting 'LNK1104' errors because Visual Studio is looking for 'mylibrarymdd.lib'.
Why is it suddenly, magically tacking on 'mdd' to the library name instead of using the .lib file I specified? And how do I get it to stop doing this?
I've found two workarounds for this problem, but don't like either one of them. Hopefully someone is able to explain why these steps were unnecessary and then all of a sudden necessary.
The first and most obvious work-around is to modify the dependency's project settings so the target output filename matches what the consuming project is expecting -- namely, 'mylibrarymdd.lib'.
The second work-around is to use "/NODEFAULTLIB:mylibrarymdd.lib". This is required for every individual dependency with the auto-naming issue.
To get to the correct (IMHO) solution, one would need to know WHY Visual Studio is creating a "default library dependency" of 'mylibraryMDD.lib' in the first place. As I stated, it wasn't doing so before and there have been no recent updates to Visual Studio or the project files themselves.
I did find that there was a change to a dependency of 'mylibrary'. It pulls in the static OpenSSL libraries and those were updated. It's unclear how that would cause the above behavior, however.
I needed SQLite for Win x64 to use in the C++ project in MS VS 2010. And I found this post with the link to x64 build, but it needs .net framework. Can I use in the my project? Also, I am about to use automated building on server side in this project, so it can be a problem to meet additional requirements (does it?).
So, does anyone have a link to precompiled SQLite DLL for x64 or I need to build it from sources? Also, if I am wrong about .net version and it is the one I need, let me know, please.
There is no official precompiled 64-bit Windows DLL of SQLite.
However, compiling it yourself is trivial: just download the amalgamation and add the .c file to your project; there are no additional configuration steps or requirements.
If you do not wish to link the library statically (or compile it directly into your application as suggested in the only answer available here so far), you can use the short tutorial I created recently. The binaries are available there as well if you need them. It uses MS VS 2015. A long time passed since your original question, but maybe someone else can find this useful.
Edit: As somebody stated below, simply providing the link is not enough, so just briefly the basics of the tutorial: You have to download the amalgamation source code from the original SQLite page and you can compile dll from it in your visual studio, but crucial is to set proper pre-processor directives for the compiler:
SQLITE_ENABLE_FTS4=1
SQLITE_ENABLE_RTREE=1
SQLITE_ENABLE_COLUMN_METADATA=1
SQLITE_API=__declspec(dllexport)
Especially last one is the one which makes your library usable. This information is not mentioned in the original instructions for building the library from the sources using the Microsoft toolchain.
Suppose I've got a cross-platform C++ library, let's call it ylib. My primary development platform is Linux. I'd like ylib to be buildable by MSVC (2008, 2010, 11, etc).
What's the best way to do this? Do I generate .vcproj files? If so, how? Ideally I'd be able to generate them without using Windows myself. No extra dependencies should be required for Windows.
Multiple variants should be build: debug dll, debug lib, release dll, release lib with dynamic runtime and release lib with static runtime.
You could use cmake for your build scripts. Cmake has the ability to generate visual studio project files from the cmake build scripts. So you'd just need to distribute your cmake files, then individual people using windows could generate MSVC project files from that.
Though as pointed out in the comments, it'd be difficult to guarantee that you could actually build your project under visual studio without trying it out yourself.
EDIT: Though I've just realized that you requested no extra dependencies on linux, which this would not solve. Unless you generated the vcproj files yourself using cmake, and distributed them. But personally I think it'd be better to just have the cmake dependency. It's freely available, and easy to install.
This also has the advantage of supporting whatever version of visual studio your end user happens to have, without the need for distributing several different formats.
You just need to understand the format of vcproj files and then write them - they are simply XML.
I don't know how well MSFT document the settings (not very if history is a guide) - so for simple projects I would just create a project in MSVC and look at what it writes.
Alternatively you could just use cmake which already does this.
I have an unmanaged Visual C++ project. I need to use a section defined in app configuration file without using any managed assembly.
Is there a library that comes with Visual Studio 2010 installation that can be used for this purpose?
If no such library comes with Visual Studio 2010, I suppose I will have to use a library that supports reading of XML files into memory and performing an XPath query. Which stable libraries support XML and XPath operations?
See C++ library for storing settings in XML for libraries which can read settings in XML files.
If you want something which comes with MSVC, I think the closest you get is using MSXML via a COM interface. But you will need to install the msxml redist on the target machine if it is not already installed. Maybe take a look at these 6 posts.
Do you mean the conventional windows config file (ini)? Libconfig might be helpful, http://gnuwin32.sourceforge.net/packages/libconfig.htm