Compiling Visual C++ Project on Linux - c++

I am tring to port this code to Linux
I believe OpenCV uses cmake to compile a VC++ code base in Linux, you create a dir, in that dir do cmake..., and a Makefile is generated. But I guess I would need a VC++ makefile first. My request is, at the very least, a VC++ makefile for the project above, and show it compiles the project with g++. If you can think of a general way, a tool that compile VC++, I'd like to hear about it.

CMake generates Makefile or VC++ project depending on your platform, so you'll end with a Makefile after running CMake.
However the code you mention isn't using neither OpenCV nor CMake, so I may be missing something...
There is some old tool called dsp2make for converting VC++6 to Makefile, but I doubt it'll be no-brainer. Better start with a CMakeLists.txt and list the cpp files you want to compile.

Related

CLion does not see wxwidgets partially but compiles project

I use Artix linux on OpenRC, I have installed wxwidgets with wxgtk3-dev package (version 3.1.5) from AUR and I wanted to work with that library in CLion. CLion sees it and I'm able to include anything from wx/ dir.
I have copied a hello world example from wxwidgets website and pasted it into my cpp source file and then CLion showed me a bunch of undeclired identifier errors (though some 'identifiers' like wxFrame are not 'undeclared'). But I'm able to build and run project and it works fine.
What's wrong with CLion and what can I do to fix this?
I've seen some guides but most of them tell about Windows and also they tell how to compile project that is not the problem in my case - it's compiling but CLion tells me that it won't compile (and still builds and runs it).
Here's also my CMakeLists.txt if needed: https://pastebin.com/58NwS4AP
OK I solved my problem. As you can see in my CMakeLists.txt it uses C++14. It seems that CLion can not properly handle some code from example with C++14 although it's not a problem for cmake and make to build it. I just switched to C++11:
set(CMAKE_CXX_STANDARD 11)
and now everything works!

Maintaining Makefiles and CMakeLists.txt

When you're working to very big projects with a large amount of people, maintaining both Makefiles and CMakeLists.txt could be very difficult. I know that CMakeLists.txt could generate Makefiles, but suppose that I want to compile my code by using make and in the same time, use an IDE to have a kind of intellisense. How can I achieve it?
In the scenario that I'm describing, CMakeLists.txt files will disappear, so I won't have the chance to generate solutions with them.
CMake is not a build manager!
It is a generator of files for other build managers!
So you can generate project for IDEs (Visual Studio, Xcode, CodeBlocks, ..) or generate MakeFile, or whatever you prefer and CMake supports. So I do not understand why do you maintain CMakeLists.txt and Makefiles at the same time.
Just maintain CMakeLists.txt and then generate respective Makefiles from it.
For details see CMake Documentation - generators:
Command-Line Build Tool Generators
These generators support command-line build tools. In order to use them, one must launch CMake from a command-line prompt whose environment is already configured for the chosen compiler and build tool.
Borland Makefiles
MSYS Makefiles
MinGW Makefiles
NMake Makefiles
NMake Makefiles JOM
Ninja
Unix Makefiles
Watcom WMake
Bottom line you should be able to generate files for IDE or Makefile for you favorite build manager without any complications.
In the scenario that I'm describing, CMakeLists.txt files will disappear, so I won't have the chance to generate solutions with them.
WAT? You are doing something very strange and most probably wrong and you didn't provide any details abut that.
Concerning intellisense I would say:
Visual Studio 2017 as built-in support for CMake, see announcement
CMake can generate a json file with all commands see CMAKE_EXPORT_COMPILE_COMMANDS
so you can use it to have smart clang based completion in vim
QtCreator as built-in support for CMake so you'll have completion too.
Extra tip at first: Do not try to mix both handmade make files and CMake over the whole time of the project.
The normal way is to create the make files using cmake. The extra of cmake is the cross platform and in your case the nativ support by some IDEs, eg. QtCreator, CLion(awaik). For a wide range of other IDE cmake can generate the project files.
Example Workflow using QtCreator:
Create a simple CMakeLists.txt, at least with the name of the project
Load this into QtCreator
Add source files, update the CMakeLists.txt from within QtCreator
Build from within QtCreator, repeat
But the same CMakeLists.txt will be used to create the make file on command line. Or on your build server or CI system.

After installing LLVM, how do I compile and run a small project?

After having installed LLVM, I try following the Kaleidoscope tutorial on how to build a small language.
However, trying to compile with clang++, I get several errors.
First, the IDE cannot find the include files. However, I fixed this by pointing the IDE to the include directory inside the LLVM build directory.
Next, the linker says it cannot find object files.
I am using Visual Studio 2015 and running Windows 10.
Can someone write a foolproof step-by-step guide on how to build a small app with some of the include files? This includes making clang++ aware on how to find the necessary files.
Thanks.

develop vtk in codeblocks

I installed vtk in debian6.0.6 successfully, I build a static lib. I run the examples and everything is ok.
But I want to develop in codeblocks. So I created a project in codeblocks, copy the code "cone.cxx" into my project, I set the include path and linkers. But there are compile errors like "undefined reference to...", I guess that is because it can not find the interfaces in the static lib.
I guess I need some #defines before compile my project. I can see the pre_defines in visual studio2008, but I can not get it in codeblocks because the codeblocks project use its makefile defaultly. Can I get a solution if I don't want to write a makefile?

Bullet Physics, CMake->CodeBlocks - MinGW: Doesn't find GL/glut.h?

Statistics...
My System: Windows Vista 64 bit
Library: Bullet Physics v2.78
Makefile Generator: CMake
Build system: MinGW command line, MinGW + CodeBlocks
Makefiles were implemented by command line and through CMake-generated Code::Blocks project
In both cases, the build fails near 30%. NOTE: I did have to switch the build executable in the Code::Blocks project from make.exe to mingw32-make.exe
First Failure: Demos\OpenGL\GLDebugFont.cpp -> GL/glut.h: No such file or directory
Second Failure (after commenting out the #include from the first) -> Demos/OpenGL/GlutStuff.h: same error
These failures happen when I build command-line OR through the generated C::B project.
Why can't it find GL/glut.h? "bullet-2.78\Glut\GL\glut.h" exists. Maybe there's a way I can tell it to find glut there?
NOTE: During the CMake makefile generation, CMake did tell me that "You are using the obsolete GLU package, please use OpenGL instead." It continued as normal with the Makefile generation. Maybe I need to define some environment variables? Maybe I need to configure something in Windows that CMake is looking for?
I would add a compiler search path in bullet-2.78/Glut, but Code::Blocks doesn't allow that if you're using a custom makefile (like a CMake-generated one).
UPDATE: I have been able to build the library itself, by building specific targets in the Code::Blocks project. However, I have been unable to build any of the demos or the benchmark test, since they all use OpenGL (and apparently glut.h). I would still like to compile those.