How to compile the Zlib source code using Cmake - c++

I'm trying to use the zlib library in a Visual Studio project I'm writing in C++ but I'm not quite sure how to compile it. I'm running Windows 7 and the source has a makefile so I figured I'd just download Cmake to compile it. Cmake ran perfectly fine with no errors (but 13 warnings) but now I'm left with what can be seen in the image below. What is my next step to compile the code? I figured Cmake would compile it since I had to specify Visual Studio when running Cmake. When trying to open the project files (which is what Cmake yielded) and attempting to compile the source that way, I get a weird access denied error. So yeah, have I gone about this process wrong?
Here's what I see after running Cmake

If I recall correctly, zlib does have the solution file included. It's in
contrib\vstudio\vc14
Try again compiling with that.

CMake is a high-level build manager, it produces a low-level build process files.
You choose to use Microsoft Visual, so it output MSVC project files (.vcproject and .sln). Next step is to open those files with Visual as you did.
So yeah, have I gone about this process wrong?
No you haven't. That weird access denied error must be investigated though.

Related

Visual Studio Code: path of files in CMake Tools tab is incorrect

I hope this is not a duplicate, as I have been searching the web for a while looking for solutions to my issue.
So, I am working in this C++ project from the lab I work at which works just fine in CLion and Visual Studio. However, I'm trying to run it in my local machine with Visual Studio Code and have installed the extensions C/C++ and CMake Tools by Microsoft, and CodeLLDB by Vadim Chugunov.
When I open the folder which contains the CMakeLists.txt file and locate it with the CMake extension, the project is detected and mounted just fine in the CMake tab. The project structure is there, and I can even build it. However, I am not able to access the files through the CMake tab (to edit them and insert breakpoints), as I get this error:
Unable to open 'main.cpp': Unable to read file
'/home/leonardo/Git/MPMc/MPMc/cmake/Git/MPMc/MPMc/MPM/main/main.cpp'
(Error: Unable to resolve non-existing file
'/home/leonardo/Git/MPMc/MPMc/cmake/Git/MPMc/MPMc/MPM/main/main.cpp').
I see it is reasonable that the program cannot read the file, as its address is looped within itself. So what I really wanted was to know how to avoid this behavior so VS Code could see the real address of the files and allow me to access them.
BTW, I am running a Manjaro 18 system and didn't have the same problem with the lab machine, which runs Debian 10.
Could you guys give me any tip as to what could be the solution to this issue? Is this a VS Code issue or a system issue?
Thanks!

SDL2 possible linking issue in VS2017

I'm using Visual Studio 2017 with OpenGLESApp template and I'm trying to put SDL2 into my project. I linked it by clicking Android.NativeActivity properties and in there I selected include folder and in linking part I linked against pre-compiled x86 binary which I downloaded from official SDL2 webpage.
Now since I'm using emulator with x86 base image I'm assuming that those things are compatible. Is my assumption wrong?
When I try to use SDL2 functions in my code compiler is complaining with the following error message:
Error MSB6006 "clang.exe" exited with code 1.
And when I delete all usages of SDL2 functions code compiles just fine. Now this would perhaps indicate that architectures are not compatible and that my initial assumption is wrong.
Can somebody help me to understand this? Is there any way I can see more information from the compiler to validate what the actual issue is?
Also, any help on how to get SDL2 to run in my project would be helpful.
You probably have undefined references in your output before the error you are showing.
You are trying to link windows libraries with Android binaries, which cannot work, they are not the proper type. Even if they both can be executed on a x86 machine, they have a different structure.

Qt command error when nmake the odbc files

I'm new for C++ and Qt.
Recently, I was learning Qt with MS SQl, but I met a problem when compiling the odbc files.
Firstly I run qmake and it goes well. But when I use nmake, the following errors happened:
module machine type 'x64' conflicts with target machine type 'x86'
I encountered similar problem just today.
Same as you,
I tried almost all comand tools include the one in qt, vs2015 x86,x64
command prompt, and cross tools as well. But none of them works.
I solved the problem by the following:
Deleted the whole project and its folder completely.
Created the project anew.
Made sure %PATH% variable, aside from irrelevant paths, contained only path to proper Qt build. In my case %PATH% contained 'C:\Qt\5.5\msvc2013_64\bin'. By proper i mean, of course, a Qt build that was built using the same compiler I was trying to compile with.
Then I ran VS2013 x64 Native Tools Command Prompt.
Switched to the project folder.
Then i did qmake and then nmake and it was all OK.
I think the problem was that, as drescherjm suggested,
If you tried one time with the wrong command prompt then tried again on the same build folder you build folder would have been broken by the bad try.
and therefore,
You will have to clean build between tries.
Thanks to drescherjm and Herman Nurlygayanov, the problem is finally solved.
Here is some experience I get from this problem:
The version of Qt creator whether 32-bit or 64-bit should be made sure before all these stuff by checking the About Qt creator. It is important to choose the right version of command prompt before compiling.
Besides, If a 32-bit command prompt is used, then vcvars32.bat should be executed. As for 64-bit version, vcvarsall.bat should be executed. They are located in %dir of you vs%/vc and %dir of you vs/vc/bin respectively.
If any error happened during one compiling, another qmake must be executed in next attemption.

Building Qt cross compile from windows

[edit] Sorry, I out thought myself. I was using a .bat file to set environment variables that wasn't set up properly. When I went to a straight VS2005 command prompt, the configure ran fine. Sorry for the noise.[/edit]
I'm trying to compile qt-everywhere-opensource for embedded. I'm using MSVC2005. However, I guess I am confused on the process. I am getting compiler errors during the configure step. I thought the configure step was just trying to generate the needed makefiles, so I'm not sure what it is trying to compile.
I expected to modify the mkspec, but I'm not sure if during configure I should point to windows headers or sdk headers. I know during the build phase I should point to sdk headers, but I'm not getting that far.
I can change the errors by modifying INCPATH, there's also a QMAKE_INCDIR that seems to have an effect. It occurred to me that since I pulled the source, maybe configure needs to build the compiler tools, in which case I should point to MSVC headers. I also tried downloading the SDK and adding the path to it's bin folder to my path ahead of the -everywhere- source, but that didn't fix the problem and I don't want to jack up my system too much testing things.
Hope someone out there can help!
When you install Qt from source under Win32, you must:
Extend the PATH variable to include $(QTDIR)\bin, where $(QTDIR) is the directory where you installed Qt.
Open a Visual Studio command prompt in $(QTDIR); a plain old Windows command prompt won't do (unless you run vcvars.bat to load Visual Studio's environment variables; but opening a Visual Studio command prompt directly is better).
At this point, configure should run properly, after which you can run nmake.
I suggest that you clear your previous installation attempts from your system before you try these steps.

How to use Microsoft C++ compiler with NetBeans?

I was wondering whether it's possible to use Microsoft's C++ compiler and linker with NetBeans IDE?
If so, what's the best way of doing it.
P.S. I'm not interested in Mingw.
EDIT: Is it possible to get NetBeans to do error parsing (so that I can click on error and have NetBeans open the right file), intellisense, etc? I know NetBeans can work with g++ make files. Why not with nmake?
I am currently writing a plugin/toolchain to use Visual C++ on Netbeans.
You can find the project called VCC4N on source forge or on NetBeans plugins.
To be honest, I always do my spare time coding inside an ide (e.g. code::blocks, monodevelop, anjuta) or an editor (virtually always scite), and the compiling I do in a terminal via a makefile (handwritten, cmake, automake).
This isn't really a problem w.r.t. time to compile: F7 (or some other of the F keys) vs. (alt+tab, up, enter), where (alt+tab) and (up) are pressed nearly at the same time, but I get the great benefit of having up to full screen compiler reports, and often I am anyways testing my programs in a terminal. Also, it makes my code more independent of the IDE (ever tried to get a makefile from code::blocks for distribution purposes?).
The visual studio compiler is called cl.exe and the linker is link.exe. These are present in particular visual studio directories. From inside visual studio > project properties > C++ > Command Line, or by disabling "Suppress Banner" option there, you can find the command that visual studio runs. You can call these command lines from inside netbeans.
Getting all the file names into the list to compile may be more tricky. You need a build system for this. You can try to use the same mechanism that visual studio uses, but sorry my knowledge fails there. Alternatively, you can use CMake or some other build system. Then, whenever you add/delete a source file, you would have to update the CMakelist.txt to be able to compile.
You can get syntax highlighting, code graphing etc from netbeans without having a compiler installed I think (not certain, you may need cygwin or mingw for parsing). What you must do is create at least an empty makefile. If you want to use Microsoft's compiler then you either need to:
a) Write the makefile yourself to compile eveything using cl
b) Call on msdev from the makefile with the project name and it will compile everything
b) Call something like scons from the makefile to compile everything
I use netbeans to develop cross platform software, at this time though, I don't actually run the builds from netbeans.