Setting up Kdevelop - visual-c++

I'm trying to setup Kdevelop and am getting a compiler error.
C:/Users/alexm/projects/SFMLGL/build> "C:/Program Files/CMake/bin/cmake.exe" "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" "-DCMAKE_BUILD_TYPE=Debug" C:/Users/alexm/projects/SFMLGL
-- The C compiler identification is unknown
CMake Error at C:/Program Files/CMake/share/cmake-3.6/Modules/CMakeDetermineCompilerId.cmake:141 (file):
file problem creating directory:
C:/Users/alexm/projects/SFMLGL/build/CMakeFiles/3.6.1/CompilerIdCXX
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.6/Modules/CMakeDetermineCompilerId.cmake:40 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
C:/Program Files/CMake/share/cmake-3.6/Modules/CMakeDetermineCXXCompiler.cmake:113 (CMAKE_DETERMINE_COMPILER_ID)
CMakeLists.txt:2 (project)
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:2 (project):
The CMAKE_C_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.
CMake Error at CMakeLists.txt:2 (project):
The CMAKE_CXX_COMPILER:
cl
is not a full path and was not found in the PATH.
To use the NMake generator with Visual C++, cmake must be run from a shell
that can use the compiler cl from the command line. This environment is
unable to invoke the cl compiler. To fix this problem, run cmake from the
Visual Studio Command Prompt (vcvarsall.bat).
Tell CMake where to find the compiler by setting either the environment
variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.
-- Configuring incomplete, errors occurred!
See also "C:/Users/alexm/projects/SFMLGL/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/alexm/projects/SFMLGL/build/CMakeFiles/CMakeError.log".
*** Failure: Exit code 1 ***
I've been googling a lot and read that I should download "Make", so I have and it did reduce the amount of errors I have, but I still have this and I don't understand a word of it.
I think it wants me to download a C compiler? How would I go about doing this?

The default toolchain for CMake tries to use the Visual Studio C++ Compiler.
If you want to use Visual Studio (you need to have that installed) you can run your CMake command from the »VS201X x64 Native Tools Command Prompt« shortcut in the start menu.
An alternative would be to use GCC for Windows via mingw-w64 which is available in msys2. There you would have to install the compiler via pacman -S mingw-w64-x86_64-toolchain and optionally cmake too via pacman -S mingw-w64-x86_64-cmake.
You could then run your command from the mingw64 prompt of msys2.
If you want to use that in KDevelop you’d have to add your msys64/mingw64/ folder to the path, or start it from the Visual Studio command prompt mentioned above. I’m not sure if there is an easier way.
Your question raises the question^^ what you want to achieve in the end. You don’t seem to know about which compiler to use (this may be important if you have binary dependencies) or what make is (which is a bit alarming).

Related

Trying to compile Detours.lib as 32bit on a 64bit machine: LNK1112: module machine type 'x86' conflicts with target machine type 'x64'

I'm trying to compile Detours per the instructions. I'd like to compile 32 bit versions of the library, since I plan to hook a 32-bit application. I've googled for answers but they seem to explain the obvious, like switch to 64-bit, but I intend on compiling for 32-bit.
I've used a mix following commands, trying to get it to work:
SET DETOURS_TARGET_PROCESSOR=X86
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat"
NMAKE
However this results in the following errors:
1) During VCVARSALL:
[ERROR:team_explorer.bat] Directory not found : "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer"
[vcvarsall.bat] Environment initialized for: 'x86'
2) During NMAKE
LIBCMT.lib(chkstk.obj) : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'
As you can see, despite my best efforts, it is complaining about the target machine type.
I have also tried vcvarsall x64, paired with SET DETOURS_TARGET_PROCESSOR=X86. (Not sure if this is a valid test) This resulted in
iping_d.obj : error LNK2001: unresolved external symbol iping_ProxyFileInfo
Please help me understand what I am doing wrong.
When I choose DETOURS_TARGET_PROCESSOR=X64, it compiles successfully, but it creates a 64-bit lib which I cannot use in my 32bit dll.
I've also tried all this from the VC x86 Native Tools Command Prompt, with the same results.
I've written up an answer to this question on the detours issue tracker, here: https://github.com/microsoft/Detours/issues/98.
Reposting the content here for convenience:
I think the issue here is that you are using the wrong configuration for cross compilation.
To cross compile x86 binaries on a x64 host, you need to:
Launch a "x64_x86 Cross Tools Command Prompt for VS" command prompt.
set DETOURS_TARGET_PROCESSOR=X86
I think you might have accidentally launched a "x86_x64 Cross Tools Command Prompt for VS" command prompt.
If I do this, and then set DETOURS_TARGET_PROCESSOR=X86, I can reproduce the same error. I imagine the same thing would happen if I did the inverse to cross compile for X64.
The naming is very confusing, but you can easily verify by checking the environment variables that are set in the command prompt.
x64_x86 Cross Tools Command Prompt:
C:\>set | findstr VSCMD_ARG
VSCMD_ARG_app_plat=Desktop
VSCMD_ARG_HOST_ARCH=x64
VSCMD_ARG_TGT_ARCH=x86
Note: VSCMD_ARGT_TGT_ARCH is equal to the architecture we are targeting, and should be equal to DETOURS_TARGET_PROCESSOR.
x86_x64 Cross Tools Command Prompt:
C:\>set | findstr VSCMD_ARG
VSCMD_ARG_app_plat=Desktop
VSCMD_ARG_HOST_ARCH=x86
VSCMD_ARG_TGT_ARCH=x64
We can see here that the the values are inverted from what we want.

how to prevent cmake from stripping the created shared library

When running the executable in the debugger, I don't see any meaningful stacktrace for the shared library -- but only the address of the function and the path of the shared library.
This applies to cmake version 3.7.2.
CMake does not strip your debug symbols by default.
You need to compile your shared libs with proper debug options, e.g.
cmake -DCMAKE_BUILD_TYPE=Debug ..
Or you can modify your CMakeLists.txt to add the debug flags.
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wall")
Edit
CMake is a build scripting tool, itself does not do stripping on your binary, but you can ask it to help with this if you want. See my other post here: Android NDK path variable for **strip** command in CMake build tool chain
Below lines will do symbol stripping if you want to let CMake to strip your debug symbols.
add_custom_command(TARGET ${SHARED_LIBRARY_NAME} POST_BUILD
COMMAND "<path-to-your-bin>/strip" -g -S -d --strip-debug --verbose
"<path-to-your-lib>/lib${SHARED_LIBRARY_NAME}.so"
COMMENT "strip debug symbols done on final binary.")
For the warnings, you can choose to have it or not, doesn't really matter.
Get back to the question and clarify further, in order to have debug symbols, you need to build your binary in DEBUG or RelWithDebInfo build type by typing below cmake command.
cmake -DCMAKE_BUILD_TYPE=Debug ..
or
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
If you are building C source code (not the cpp which I assumed), then you can check the corresponding CMAKE_C_FLAGS.
See the official document from here: https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html

While building libcxx using clang-cl, I get CMake error "include could not find load file: AddLLVM"?

I have just successfully built llvm, clang and lld on msvc build tool 2017 with windows 10 sdk.
I tried to build libcxx next.
While I was doing cmake/ninja (with clang-cl of newly built clang), I got this:
CMake Error at test/CMakeLists.txt:72 (include):
include could not find load file:
AddLLVM
CMake Error at test/CMakeLists.txt:74 (configure_lit_site_cfg):
Unknown CMake command "configure_lit_site_cfg".
-- Configuring incomplete, errors occurred!
I did also pass this parameter to cmake
-DLLVM_PATH="C:/llvm"
Is this because I built llvm wrong?
UPDATE
I already fixed this by
-DCMAKE_MODULE_PATH="C:/llvm-master/cmake/modules

cmake doesn't find Qt5

Last night I tried to download the disassembler called "Evan's debugger (edb)", that has similar GUI to Ollydbg (Linux only).
I tried to build them via terminal using:
sudo cmake ../edb_folder
With ../edb_folder being the directory containing edb's source code.
It gives me the following error about Qt5:
-- Boost version: 1.58.0
-- Checking for module 'libgvc>=2.38.0'
--
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake:26 (find_package):
Could not find a package configuration file provided by "Qt5Svg" with any
of the following names:
Qt5SvgConfig.cmake
qt5svg-config.cmake
Add the installation prefix of "Qt5Svg" to CMAKE_PREFIX_PATH or set
"Qt5Svg_DIR" to a directory containing one of the above files. If "Qt5Svg"
provides a separate development package or SDK, be sure it has been
installed.
Call Stack (most recent call first):
src/CMakeLists.txt:26 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/kanna/Desktop/build/CMakeFiles/CMakeOutput.log".
But I already have Qt5 installed on my system (see this picture). Why can't cmake find Qt5?
(FYI: I'm using ubuntu 64bits)
go to synaptic and install libqt5svg5 + libqt5svg5-dev + libqt5svg5-private-dev

Can't run the prepare.py script on linphone-android project

I want to build linphone for android on android studio,
I follow the guide on https://github.com/BelledonneCommunications/linphone-android,
but on step 3, I keep getting exception:
CMake Error: CMake was unable to find a build program corresponding to
"Unix Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need
to select a different build tool. CMake Error: CMAKE_C_COMPILER not
set, after EnableLanguage CMake Error: CMAKE_CXX_COMPILER not set,
after EnableLanguage
-- Configuring incomplete, errors occurred!
Did I miss any setting on cMake? I just wanna make it work on android studio.
Update my final solution:
Those make/build libraries all from Linux kernel, so I finally giving up to build linphone on Windows and it works like a charm on Linux.

Resources