How to Compile: Synergy on mac (new toolchain from 2017) - c++

I know a question on that topic already exists (How to Compile: Synergy on mac) but it looks like the old toolchain was deleted by a change on January 26 2017.
They use cmake now to handle the build but I was not successful on building it properly on MacOs Sierra (it complains about assert.h missing -.-). If I fix it by adding /usr/include/ to the include paths the build then complains about not finding CoreServices/CoreServices.h
Reaching that point I think that I must be missing something vital to build it properly but what ?
Steps I followed:
git clone https://github.com/symless/synergy
cd synergy
mkdir build
cd build
cmake ..
make
# there it complains about not finding assert.h

You have to specify CMAKE_OSX_SYSROOT in the cmake command. This is from Compiling · symless/synergy-core Wiki · GitHub:
cmake -DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 \
-DCMAKE_OSX_ARCHITECTURES=x86_64 ..
You can leave the 10.9 for the target as it is, but change /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk to match the actual path on your system if it's different.

Related

How to build gstreamer from source code using meson?

OS: Windows 10
Compiler: gcc x86-64 8.1.0
I cloned repo:
git clone https://gitlab.freedesktop.org/gstreamer/gstreamer.git
Started meson:
meson \path\to\directory
And next start ninja
ninja
And I get error:
fatal error: glib.h: No such file or directory
I thought that everything what I need is in this repo. Am I wrong?
I guess meson outputs "glib2 not found".
You might need to install glib2.
And make sure glib-2.0.pc exists on "/usr/local/lib/pkgconfig" or $PKG_CONFIG_PATH dir.
meson search pkgconfig dir first for find out package.

Importing a CMake project into CodeLite

I was wondering if anyone knew of a way to import an existing cmake project into the CodeLite IDE?
This is a C++ project and I have all of the .c and .h files. I have the CMake lists and what not for the project too.
I am running on Ubuntu 16.04 with CodeLite 11.0.4.
If CodeLite is not able to do this, then is there an IDE that can import a CMake project?
You can generate a CodeLite workspace with cmake by using the -G option. First, look up all available CodeLite generators by doing
cmake --help
Keep in mind that not all might work for you, depending on your system configuration. Then use one of them as you like. For example, using Ninja you can do:
cmake -G "CodeLite - Ninja" /path
where /path is the directory where your CMakeLists.txt is located.
You can generate Codelite workspace with cmake by:
cmake -G "Codelite - Unix MakeFiles" /path (where 'path' your CMakeFiles.txt is present)
For instance:
Generate Codelite workspace
cmake -G "CodeLite - Unix Makefiles" **./**
Codelite workspace is generated
Open CodeLite and build project (P.S. do not forget to set up project appropriately (e.g. compiler / workspace settings)
According to Some programmer dude, CMAKE is able to make a codeLite project. I have tested this with the version of CMAKE that you can install with sudo apt-get install in ubuntu 16.04. This works.

CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles"

I am trying to use cmake to build the Box2D library for c++. When I run cmake gui I get the error:
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMake was unable to find a build program corresponding to "MinGW 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!
Most questions like these people have answered by saying "Add MinGw/bin to the PATH" but I already have that on the PATH. What else could be causing this error?
mingw32-make.exe can be installed with the standard MinGW32 installer via the appropriate checkbox:
As rubenvb points out, you'll still need to ensure that it makes it into your PATH. If you edit your environment variables via System Properties, be sure to close and reopen the CMake GUI.
If you're more accustomed to using make.exe, install MSYS and use MSYS Makefiles as the CMake generator. You'll also need to put both mingw\bin and msys\1.0\bin into your PATH.
I had the same problem and I added these three to my system path and errors were solved.
C:\Program Files\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin
C:\Program Files\CMake\bin
C:\opencv\build\install\x64\mingw\bin
You can check this answer: https://stackoverflow.com/a/74240235/3110429
Firstly check the system.
Install MINGW https://www.msys2.org/
Install gcc, g++, gdb, and cmake using pacman.
pacman -S mingw-w64-x86_64-gcc
pacman -S mingw-w64-x86_64-gdb
pacman -S mingw-w64-x86_64-cmake
Check installation:
gcc --version
g++ --version
gdb --version
Edit environment variables for your account (PATH)
C:\msys64\mingw64\bin
For cmake project on Vscode:
Create a cmake project: https://code.visualstudio.com/docs/cpp/cmake-linux#_create-a-cmake-project
Choose the Kit (Toolchain) which was installed before
Set cmake.cmakePath (If you installed with pacman, the path should be same as gcc/g++.
"cmake.cmakePath": "C:\msys64\mingw64\bin\cmake.exe"
Reset VScode: Ctrl+shift+P and type "CMake:Reset CMake Tools for Extension State"
Configure project: Ctrl+shift+P and type "CMake: Configure". You will see "built" directory and generated files.
In the path MinGW\bin try to find make.exe or mingw32-make.exe. If you don't have it then mingw32-make.exe can be installed with the standard MinGW32 installer as shown in the pervious answer.
Then have a second copy of make.exe or mingw32-make.exe to have identical two files with those names make.exe and mingw32-make.exe
and it solved my problem.

CMake error no CMAKE_C_COMPILER could be found using Xcode and GLFW

I'm trying to follow this tutorial to get started with OpenGL: http://www.learnopengl.com/#!Getting-started/Creating-a-window and it requires downloading glfw and CMake.
I have set the downloaded glfw folder as the source code folder and I have created inside that folder another one called "build" which I then set as the build one for the binaries, as the tutorial asks.
I click on "Configure" and I select XCode as the Generator, since I'm on a Mac.
The problem is that when I try to configure the project CMake gives me this error:
The C compiler identification is unknown
CMake Error at CMakeLists.txt:3 (project):
No CMAKE_C_COMPILER could be found.
Configuring incomplete, errors occurred!
See also "/Users/standard/Desktop/glfw-3.2.1/build/CMakeFiles/CMakeOutput.log".
See also "/Users/standard/Desktop/glfw-3.2.1/build/CMakeFiles/CMakeError.log".
I've already read this question, but as far as I can understand, it doesn't have what I need:
CMake error at CMakeLists.txt:30 (project): No CMAKE_C_COMPILER could be found
If you have installed Xcode or Command Line Tools for Xcode, try this:
sudo xcode-select --reset
This happened to me with Xcode10 / Cmake 3.12 after installing Homebrew. Running sudo xcode-select --reset fixed it for me.
Did you install Xcode and Xcode Commandline Tools?
xcode-select --install
If you have Xcode Commandline Tools installed, you should no longer be receiving the xcrun is missing error.
How did you install Cmake? Once you have ensured that Xcode Commandline Tools is installed, please completely remove Cmake from your system and reinstall it. You have a screwed up configuration. There are ways to debug and fix it without a clean install, but since you are new to this, it will be the easiest and lest frustrating way.
Failing that if you do have Xcode Commandline Tools installed, hstdt suggested trying this:
sudo xcode-select --reset
This error means CMake cannot find your standard C/C++ Compiler, looks like you'll need to export the environment variables yourself. you can find the path of your C/C++ compiler with:
xcrun -find c++
xcrun -find cc
Then afterwards when you have the paths, create two variables inside the gui. If you are running it from the cline, it would be something like
cmake -D CMAKE_C_COMPILER="/path/to/your/c/compiler/executable" -D CMAKE_CXX_COMPILER="/path/to/your/cpp/compiler/executable" ...
On a fresh Xcode install the command line tools complain about agreeing to the EULA which build tools don't like. Which you can do with:
sudo xcodebuild -license
If you are on a Mac computer and have Homebrew, you can simply upgrade cmake, forcing the compiler to be reconfigured:
brew upgrade cmake
In my case, I needed to install CMake from CMake official site, download the .dmg, install it and then add the CMake folder the system's PATH.
Before the installation, the output of which cmake is /usr/local/bin/cmake.
After the installation it should be something like /Applications/CMake.app/Contents/bin/cmake.
This has solved the issue for me.
I get exactly this error if ccache is enabled on my machine. Disabling ccache fixed the problem for me.
To check if ccache is enabled, print the systems variables CC or CXX:
echo $CC
echo $CXX
This prints something like the following: ccache clang -Qunused-arguments -fcolor-diagnostics. (CC or CXX are typically overridden by the .bashrc or .zshrc file.)
To disable ccache, use the following:
CC=clang
CXX=clang++
Then rebuild the cmake project:
cmake -G Xcode <path/to/CMakeLists.txt>
Apparently, it is possible to use CMake's Xcode generator also in combination with ccache, as is described here. But I never tried it out myself.
I got this error when I had an invalid value set for CMAKE_OSX_SYSROOT. I was trying to give it the name of the SDK e.g. "macOS 10.13". Setting it to the full path of the SDK resolved the issue.
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk
Compiler detection appears to be broken with Xcode 10 and older versions of CMake. I know that it broke for me with CMake 2.2 and upgrading to the latest (2.13) solved it for me. It was working fine with Xcode 9 and it broke with the upgrade. I tried the other solutions (all good depending on your situation) but upgrading CMake fixed the issue.
If you are on CLion and facing this issue try changing the C and C++ compiler location inside Toolchains settings to the latest one. the default GCC installation directory is /usr/local/Cellar/gcc/...
after I upgrade Xcode to new verison, I met this error, then I upgrade my cmake version, problem solved.
For anyone coming to this question nowadays from google, my problem was fixed via
xcodebuild -runFirstLaunch
I found this by inspecting CMakeFiles/CMakeError.log

install wx-widgets is driving me insane on Yosemite

I'm on Mac OS X Yosemite 10.10.2. As far as I know, wx-widgets were preinstalled on older versions on OS X (probably that's why google search doesn't help), but that's not the case anymore. I need to get started on a C++ project using wx-widgets, using any IDE (Eclipse, Codelite, or whatever is best). However, I simply cannot get wx-widgets to work. After a workaround I was able to compile on my machine wxWidgets-3.0.2. I called from terminal make and make install, but the libraries seem to not be correctly installed. Indeed, if I create a project on Codelite I get many "wx-config: Command not found" errors. Can someone help me to get me started on installing the libraries and creating a simple project that includes wx-widgets?
I use homebrew which is installed by copying and pasting one line from the homebrew website.
Then, the installation of wxWidgets is simplicity itself with:
brew install wxmac
Any problems, you just call the doctor with
brew doctor
Now you have a proper package manager you can install ImageMagick, GNU Parallel, GNU awk, Oxygen, webkit2html, zeromq, tree, SDL, Redis, sqlitebrowser, pandoc, exiftool, ffmpeg, 7zip, awscli, etc...
You can then compile your wxWidgets programs with
g++ `wx-config --cxxflags` -o sample sample.cpp `wx-config --libs`
I can successfully compile and install wxWidgets on Yosemite with these commands:
- Get the latest sources of wxWidgets 3 from wxwidgets.org and unpack them.
- Move the unpacked directory someplace where you want to keep it.
- Open a terminal and change into the wxwidgets directory.
- Create two directories: build-release and build-debug (don't rename those!)
- Change into wxwidgets/build-release
- Run
../configure --with-osx_cocoa --disable-shared --with-opengl --enable-universal-binary=i386,x86_64 --with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk --with-macosx-version-min=10.6
- Run make, then sudo make install
- Change into wxwidgets/build-debug
- Run
../configure --enable-debug --with-osx_cocoa --with-opengl --enable-universal-binary=i386,x86_64 --with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk --with-macosx-version-min=10.6
- Run make, then sudo make install
Be aware that these instructions are for compiling against the Mac OS X 10.6 SDK, which I have at /Developer/SDKs/MacOSX10.6.sdk. You can try to omit the --with-macosx-sdk parameter altogether, which will compile using the latest SDK. Also ensure that you have Xcode and the command line developer tools installed.
These commands will install static libraries for the release build and shared libraries for the debug build. You can change this by supplying or omitting the --disable-shared parameter.
The instructions for building and installing wxWidgets are included in the distribution and can also be viewed online.
If your IDE doesn't find wx-config, you must not have the location where you installed it (/usr/local/bin) by default in your PATH. Add it there to fix this.
Like suggested by VZ, you must change your PATH.
But not the variable PATH in your environment Windows but the variable PATH in your C++ project. It's strange but maybe it's different.
Go into (for eclipse) :
C/C++Build->Environment->PATH (add the path of wx-config in the beginning).
Press : Apply, OK and build the project.
I think is strange that Eclipse don't update the PATH after rebooting the OS. Maybe we must add an option to Eclipse for building WxWidget and force Eclipse to update the PATH, but I don't know it.
This change work for me.
Eclipse / MinGW-MSYS / WxWidget 2.8