swift-lldb compilation fails with c++11 error - swift

I am trying to compile swift-lldb on Ubuntu 14.04 (following instructions from https://github.com/apple/swift-lldb). I have the following dependencies installed:
Clang-3.5
Cmake version 3.5.2
Python version 2.7.6
On running the build script step which is lldb/scripts/build-swift-cmake.py --test, I am seeing the following error:
CMake Warning at cmake/modules/HandleLLVMOptions.cmake:185 (message):
-fPIC is not supported.
Call Stack (most recent call first):
cmake/modules/HandleLLVMOptions.cmake:216 (add_flag_or_print_warning)
CMakeLists.txt:616 (include)
CMake Error at cmake/modules/HandleLLVMOptions.cmake:429 (message):
LLVM requires C++11 support but the '-std=c++11' flag isn't supported.
Call Stack (most recent call first):
CMakeLists.txt:616 (include)
I have defined environment variables CC and CXX to point to the clang C and C++ compilers.
root:/myswift# echo $CC
/usr/bin/clang
root:/myswift# echo $CXX
/usr/bin/clang++
I also found in the clang documentation that c++11 is supported by clang-3.5. Not sure what I am missing here. Can someone please help?

clang-4.0 mentioned as part of the installation should support the -std=c++11 flag (just tested clang-4.0.1). However, upgrading to clang-6.0 seems to solve this build process error.
Running cmake directly in the automatically created build directory (by the swift build scripts) could be used to investigate the build failure in more detail. To specify compilers here, rather than setting CC and CXX environment variables (which works well for GNU configure scripts), compilers can be set for cmake via
cmake -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ path_to_src_or_build_directory
An existing CMakeCache.txt might have to be removed, so that the above parameters are honored.
A problem with clang++ installations that I have observed is that clang++ cannot find C++ headers (i.e. if C++ headers are in non-standard locations other than /usr/include, unlikely in the case of Ubuntu though). In case /usr/bin/clang++ cannot compile a simple program like
#include <iostream>
using namespace std;
int main() {
cout << "hello" << endl;
return 0;
}
not being able to find the iostream include file, it might help to set --gcc-toolchain=/pathtoaworkinggcc, where pathtoaworkinggcc should include include, lib, bin, etc. of a working C++ compiler (possibly g++ in the case of a Ubuntu installation).

Related

msbuild: command line error D8021: invalid numeric argument /Werror

I am a student of TU Wien and quite new in programming. I would like to install a GitHub repository (https://github.com/SICKAG/sick_safetyscanners_base) which is basically for Linux, but I asked one the of the contributors and he said it should work on windows too.
According to the README the following steps have to be done to install this the repository:
git clone https://github.com/SICKAG/sick_safetyscanners_base.git
cd sick_safetyscanners_base
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=<path to install folder> ..
make -j8
make install
Here is a list of the softwares and tools I have already installed:
Visual Studio 2022 Community (because of MSVC)
Visual Studio Code
Scoop (to install cmake and make)
Boost 1.80.0
Git
And here are all the commands which are just working fine:
git clone https://github.com/SICKAG/sick_safetyscanners_base.git
cd sick_safetyscanners_base
mkdir build
cd build
cmake -DBoost_USE_STATIC_LIBS=ON .. (-DBoost_USE_STATIC_LIBS=ON, otherwise cmake does not find boost)
The problem is in the command line "make -j8". After this command, I recieve the following message: *** No targets specified and no makefile found. Stop. I have done some research and I found out that make will not work on windows (I use windows 10).
PS C:\Users\ader\sick_safetyscanners_base> mkdir build
Directory: C:\Users\ader\sick_safetyscanners_base
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 09/11/2022 13:04 build
PS C:\Users\ader\sick_safetyscanners_base> cd build
PS C:\Users\ader\sick_safetyscanners_base\build> cmake -DBoost_USE_STATIC_LIBS=ON ..
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19043.
-- The CXX compiler identification is MSVC 19.33.31630.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Found Boost: C:/boost/boost_1_80_0 (found version "1.80.0") found components: system thread chrono atomic
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/ader/sick_safetyscanners_base/build
PS C:\Users\ader\sick_safetyscanners_base\build> make -j
make: *** No targets specified and no makefile found. Stop.
Since Make will not work, I tried the command "msbuild" in the Developer PowerShell for VS 2022, but the repository will still not be installed, because I have the following error message: command line error D8021: invalid numeric argument /Werror.
PS C:\Users\ader\sick_safetyscanners_base\build> msbuild sick_safetyscanners_base.vcxproj
MSBuild version 17.3.1+2badb37d1 for .NET Framework
Build started 09/11/2022 13:07:41.
Project "C:\Users\ader\sick_safetyscanners_base\build\sick_safetyscanners_base.vcxproj" on node 1 (default targets).
Project "C:\Users\ader\sick_safetyscanners_base\build\sick_safetyscanners_base.vcxproj" (1) is building "C:\Users\ader\
sick_safetyscanners_base\build\ZERO_CHECK.vcxproj" (2) on node 1 (default targets).
PrepareForBuild:
Creating directory "x64\Debug\ZERO_CHECK\".
Creating directory "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\".
InitializeBuildStatus:
Creating "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
CustomBuild:
Checking Build System
FinalizeBuildStatus:
Deleting file "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild".
Touching "x64\Debug\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate".
Done Building Project "C:\Users\ader\sick_safetyscanners_base\build\ZERO_CHECK.vcxproj" (default targets).
PrepareForBuild:
Creating directory "sick_safetyscanners_base.dir\Debug\".
Creating directory "C:\Users\ader\sick_safetyscanners_base\build\Debug\".
Creating directory "sick_safetyscanners_base.dir\Debug\sick_saf.78B012DA.tlog\".
InitializeBuildStatus:
Creating "sick_safetyscanners_base.dir\Debug\sick_saf.78B012DA.tlog\unsuccessfulbuild" because "AlwaysCreate" was spe
cified.
CustomBuild:
Building Custom Rule C:/Users/ader/sick_safetyscanners_base/CMakeLists.txt
ClCompile:
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.33.31629\bin\HostX64\x64\CL.exe /c /IC:\User
s\ader\sick_safetyscanners_base\include /IC:\boost\boost_1_80_0 /Zi /nologo /Wall /WX- /diagnostics:column /Od /Ob0 /
D _WINDLL /D _MBCS /D WIN32 /D _WINDOWS /D "CMAKE_INTDIR=\"Debug\"" /D sick_safetyscanners_base_EXPORTS /Gm- /EHsc /R
TC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /Fo"sick_safetyscanners_base.dir\Debug\\" /Fd"sick_s
afetyscanners_base.dir\Debug\vc143.pdb" /external:W4 /Gd /TP /errorReport:queue -std=c++11 -Werror C:\Users\ader\sic
k_safetyscanners_base\src\SickSafetyscanners.cpp C:\Users\ader\sick_safetyscanners_base\src\cola2\ApplicationNameVari
ableCommand.cpp C:\Users\ader\sick_safetyscanners_base\src\cola2\ChangeCommSettingsCommand.cpp C:\Users\ader\sick_saf
etyscanners_base\src\cola2\CloseSession.cpp C:\Users\ader\sick_safetyscanners_base\src\cola2\Cola2Session.cpp C:\User
s\ader\sick_safetyscanners_base\src\cola2\Command.cpp C:\Users\ader\sick_safetyscanners_base\src\cola2\ConfigMetadata
VariableCommand.cpp C:\Users\ader\sick_safetyscanners_base\src\cola2\CreateSession.cpp C:\Users\ader\sick_safetyscann
ers_base\src\cola2\DeviceNameVariableCommand.cpp C:\Users\ader\sick_safetyscanners_base\src\cola2\DeviceStatusVariabl
eCommand.cpp C:\Users\ader\sick_safetyscanners_base\src\cola2\FieldGeometryVariableCommand.cpp C:\Users\ader\sick_saf
etyscanners_base\src\cola2\FieldHeaderVariableCommand.cpp C:\Users\ader\sick_safetyscanners_base\src\cola2\FieldSetsV
ariableCommand.cpp C:\Users\ader\sick_safetyscanners_base\src\cola2\FindMeCommand.cpp C:\Users\ader\sick_safetyscanne
rs_base\src\cola2\FirmwareVersionVariableCommand.cpp C:\Users\ader\sick_safetyscanners_base\src\cola2\LatestTelegramV
ariableCommand.cpp C:\Users\ader\sick_safetyscanners_base\src\cola2\MeasurementCurrentConfigVariableCommand.cpp C:\Us
ers\ader\sick_safetyscanners_base\src\cola2\MeasurementPersistentConfigVariableCommand.cpp C:\Users\ader\sick_safetys
canners_base\src\cola2\MethodCommand.cpp C:\Users\ader\sick_safetyscanners_base\src\cola2\MonitoringCaseTableHeaderVa
riableCommand.cpp C:\Users\ader\sick_safetyscanners_base\src\cola2\MonitoringCaseVariableCommand.cpp C:\Users\ader\si
ck_safetyscanners_base\src\cola2\OrderNumberVariableCommand.cpp C:\Users\ader\sick_safetyscanners_base\src\cola2\Proj
ectNameVariableCommand.cpp C:\Users\ader\sick_safetyscanners_base\src\cola2\RequiredUserActionVariableCommand.cpp C:\
Users\ader\sick_safetyscanners_base\src\cola2\SerialNumberVariableCommand.cpp C:\Users\ader\sick_safetyscanners_base\
src\cola2\StatusOverviewVariableCommand.cpp C:\Users\ader\sick_safetyscanners_base\src\cola2\TypeCodeVariableCommand.
cpp C:\Users\ader\sick_safetyscanners_base\src\cola2\UserNameVariableCommand.cpp C:\Users\ader\sick_safetyscanners_ba
se\src\cola2\VariableCommand.cpp C:\Users\ader\sick_safetyscanners_base\src\communication\TCPClient.cpp C:\Users\ader
\sick_safetyscanners_base\src\communication\UDPClient.cpp C:\Users\ader\sick_safetyscanners_base\src\data_processing\
ParseApplicationData.cpp C:\Users\ader\sick_safetyscanners_base\src\data_processing\ParseApplicationNameData.cpp C:\U
sers\ader\sick_safetyscanners_base\src\data_processing\ParseConfigMetadata.cpp C:\Users\ader\sick_safetyscanners_base
\src\data_processing\ParseData.cpp C:\Users\ader\sick_safetyscanners_base\src\data_processing\ParseDataHeader.cpp C:\
Users\ader\sick_safetyscanners_base\src\data_processing\ParseDatagramHeader.cpp C:\Users\ader\sick_safetyscanners_bas
e\src\data_processing\ParseDerivedValues.cpp C:\Users\ader\sick_safetyscanners_base\src\data_processing\ParseDeviceNa
me.cpp C:\Users\ader\sick_safetyscanners_base\src\data_processing\ParseDeviceStatus.cpp C:\Users\ader\sick_safetyscan
ners_base\src\data_processing\ParseFieldGeometryData.cpp C:\Users\ader\sick_safetyscanners_base\src\data_processing\P
arseFieldHeaderData.cpp C:\Users\ader\sick_safetyscanners_base\src\data_processing\ParseFieldSetsData.cpp C:\Users\ad
er\sick_safetyscanners_base\src\data_processing\ParseFirmwareVersion.cpp C:\Users\ader\sick_safetyscanners_base\src\d
ata_processing\ParseGeneralSystemState.cpp C:\Users\ader\sick_safetyscanners_base\src\data_processing\ParseIntrusionD
ata.cpp C:\Users\ader\sick_safetyscanners_base\src\data_processing\ParseMeasurementCurrentConfigData.cpp C:\Users\ade
r\sick_safetyscanners_base\src\data_processing\ParseMeasurementData.cpp C:\Users\ader\sick_safetyscanners_base\src\da
ta_processing\ParseMeasurementPersistentConfigData.cpp C:\Users\ader\sick_safetyscanners_base\src\data_processing\Par
seMonitoringCaseData.cpp C:\Users\ader\sick_safetyscanners_base\src\data_processing\ParseOrderNumber.cpp C:\Users\ade
r\sick_safetyscanners_base\src\data_processing\ParseProjectName.cpp C:\Users\ader\sick_safetyscanners_base\src\data_p
rocessing\ParseRequiredUserAction.cpp C:\Users\ader\sick_safetyscanners_base\src\data_processing\ParseSerialNumber.cp
p C:\Users\ader\sick_safetyscanners_base\src\data_processing\ParseStatusOverview.cpp C:\Users\ader\sick_safetyscanner
s_base\src\data_processing\ParseTCPPacket.cpp C:\Users\ader\sick_safetyscanners_base\src\data_processing\ParseTypeCod
eData.cpp C:\Users\ader\sick_safetyscanners_base\src\data_processing\ParseUserNameData.cpp C:\Users\ader\sick_safetys
canners_base\src\data_processing\TCPPacketMerger.cpp C:\Users\ader\sick_safetyscanners_base\src\data_processing\UDPPa
cketMerger.cpp C:\Users\ader\sick_safetyscanners_base\src\datastructure\ApplicationData.cpp C:\Users\ader\sick_safety
scanners_base\src\datastructure\ApplicationInputs.cpp C:\Users\ader\sick_safetyscanners_base\src\datastructure\Applic
ationName.cpp C:\Users\ader\sick_safetyscanners_base\src\datastructure\ApplicationOutputs.cpp C:\Users\ader\sick_safe
tyscanners_base\src\datastructure\CommSettings.cpp C:\Users\ader\sick_safetyscanners_base\src\datastructure\ConfigDat
a.cpp C:\Users\ader\sick_safetyscanners_base\src\datastructure\ConfigMetadata.cpp C:\Users\ader\sick_safetyscanners_b
ase\src\datastructure\Data.cpp C:\Users\ader\sick_safetyscanners_base\src\datastructure\DatagramHeader.cpp C:\Users\a
der\sick_safetyscanners_base\src\datastructure\DataHeader.cpp C:\Users\ader\sick_safetyscanners_base\src\datastructur
e\DerivedValues.cpp C:\Users\ader\sick_safetyscanners_base\src\datastructure\DeviceName.cpp C:\Users\ader\sick_safety
scanners_base\src\datastructure\DeviceStatus.cpp C:\Users\ader\sick_safetyscanners_base\src\datastructure\FieldData.c
pp C:\Users\ader\sick_safetyscanners_base\src\datastructure\FieldSets.cpp C:\Users\ader\sick_safetyscanners_base\src\
datastructure\FirmwareVersion.cpp C:\Users\ader\sick_safetyscanners_base\src\datastructure\GeneralSystemState.cpp C:\
Users\ader\sick_safetyscanners_base\src\datastructure\IntrusionData.cpp C:\Users\ader\sick_safetyscanners_base\src\da
tastructure\IntrusionDatum.cpp C:\Users\ader\sick_safetyscanners_base\src\datastructure\LatestTelegram.cpp C:\Users\a
der\sick_safetyscanners_base\src\datastructure\MeasurementData.cpp C:\Users\ader\sick_safetyscanners_base\src\datastr
ucture\MonitoringCaseData.cpp C:\Users\ader\sick_safetyscanners_base\src\datastructure\OrderNumber.cpp C:\Users\ader\
sick_safetyscanners_base\src\datastructure\PacketBuffer.cpp C:\Users\ader\sick_safetyscanners_base\src\datastructure\
ParsedPacketBuffer.cpp C:\Users\ader\sick_safetyscanners_base\src\datastructure\ProjectName.cpp C:\Users\ader\sick_sa
fetyscanners_base\src\datastructure\RequiredUserAction.cpp C:\Users\ader\sick_safetyscanners_base\src\datastructure\S
canPoint.cpp C:\Users\ader\sick_safetyscanners_base\src\datastructure\SerialNumber.cpp C:\Users\ader\sick_safetyscann
ers_base\src\datastructure\StatusOverview.cpp C:\Users\ader\sick_safetyscanners_base\src\datastructure\TypeCode.cpp C
:\Users\ader\sick_safetyscanners_base\src\datastructure\UserName.cpp
cl : befehlszeile error D8021: Ungültiges numerisches Argument /Werror. [C:\Users\ader\sick_safetyscanners_base\build\
sick_safetyscanners_base.vcxproj]
Done Building Project "C:\Users\ader\sick_safetyscanners_base\build\sick_safetyscanners_base.vcxproj" (default targets)
-- FAILED.
Build FAILED.
"C:\Users\ader\sick_safetyscanners_base\build\sick_safetyscanners_base.vcxproj" (default target) (1) ->
(ClCompile target) ->
cl : befehlszeile error D8021: Ungültiges numerisches Argument /Werror. [C:\Users\ader\sick_safetyscanners_base\buil
d\sick_safetyscanners_base.vcxproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.43
At this stage, I do not really know, what else should I try to get this lilbrary finally installed. My goal is to call it with #include in my C++ program.
Do you have a solution here on how to get rid of the error message and how to install this library? I think the only thing missing is this step. I would be very grateful for any suggestions.
Thank you in advance!
== UPDATE after the answer of MadScientist ==
Brief history: After installing boost, I got the following message...
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
C:\boost\boost_1_80_0
The following directory should be added to linker library paths:
C:\boost\boost_1_80_0\stage\lib
... but I don't know exactly where to put these paths. I'm assuming that's exactly why Cmake doesn't find Boost. This problem was solved with -DBoost_USE_STATIC_LIBS=ON.
Now, if I use the command line cmake -DBoost_USE_STATIC_LIBS=ON -G "Unix Makefiles" .., CMake fails to find Boost again.
Here is what I can see on the terminal:
PS C:\Users\ader\sick_safetyscanners_base\build> cmake -G "Unix Makefiles" -DBoost_USE_STATIC_LIBS=ON ..
-- The CXX compiler identification is GNU 12.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/mingw64/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
CMake Error at C:/Users/ader/scoop/apps/cmake/3.24.3/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find Boost (missing: system thread chrono) (found version
"1.80.0")
Call Stack (most recent call first):
C:/Users/ader/scoop/apps/cmake/3.24.3/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
C:/Users/ader/scoop/apps/cmake/3.24.3/share/cmake-3.24/Modules/FindBoost.cmake:2376 (find_package_handle_standard_args)
CMakeLists.txt:11 (find_package)
-- Configuring incomplete, errors occurred!
See also "C:/Users/ader/sick_safetyscanners_base/build/CMakeFiles/CMakeOutput.log".
PS C:\Users\ader\sick_safetyscanners_base\build>
Make absolutely does work on Windows (if you install it). In fact, you can tell it works since you ran it and it worked!!
The problem is that cmake can create project files for lots of different build systems, and the default on Windows is Visual Studio, not make. So when you ran cmake you got a bunch of files that tell Visual Studio how to build your code, but no files that tell make how to build your code.
Delete the directory and unpack it again, then run cmake again and add the -G "Unix Makefiles" option to the command.
However, the option -Werror is an option to the GCC compiler. It won't work if you're trying to run the Visual Studio compiler (even if you use a makefile to build the code, it will still use the Visual Studio compiler to compile it).
My suspicion is that whomever told you that "it should work" to build this code on Windows, was overly optimistic and in fact it will require some porting effort to make this work.

CMake couldn't find MatLab libraries, even though MatLab is detected

I have been trying to build BlockFactory and I keep getting following error when trying to build it.
PS F:\simconnect-monitor\blockfactory> cmake -S . -B build
-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.19044.
-- The CXX compiler identification is MSVC 19.16.27045.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find Matlab (missing: Matlab_MEX_LIBRARY Matlab_MX_LIBRARY ENG_LIBRARY) (found version "9.10")
CMake Error at C:/Program Files/CMake/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:165 (message):
Could NOT find Matlab (missing: Matlab_MEX_LIBRARY Matlab_MX_LIBRARY MX_LIBRARY) (found version "9.10")
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.18/Modules/FindPackageHandleStandardArgs.cmake:458 (_FPHSA_FAILURE_MESSAGE)
cmake/FindMatlab.cmake:1873 (find_package_handle_standard_args)
deps/mxpp/CMakeLists.txt:45 (find_package)
As you can see, MatLab was detected but the correct library cannot be found. I have tried with CMake 3.18.14 and 3.22.3 with no difference. I am really loss right now honestly. I have posted an issue in the BlockFactory GitHub but so far, it is still unresolved.
So, I found the solution. I am using VS2017. By default for VS2017, cmake makes 32-bit project. You have to pass cmake -A x64 to force it to a 64-bit project. In addition to that, though, I have to force finfmatlab.cmake to only look for 64-bit library by basically setting _matlab_64build to always be true. Make sure you have 64-bit MatLab if you do this.
Edit: Alternatively, you can install VS2019 instead since it defaulted to 64-bit project.

Building Swift on CentOS

I am building Swift compiler from source on CentOS 6, and am running into a library issue. After fighting with the build script for a while I have got where running ./utils/build-script eventually gives:
+ /home/src/cmake-3.4.1-Linux-x86_64/bin/cmake --build /home/src/swift/build/Ninja-DebugAssert/cmark-linux-x86_64 -- all
ninja: no work to do.
llvm: using standard linker
+ cd /home/src/swift/build/Ninja-DebugAssert/llvm-linux-x86_64
+ /home/src/cmake-3.4.1-Linux-x86_64/bin/cmake -G Ninja -DCMAKE_C_COMPILER:PATH=clang -DCMAKE_CXX_COMPILER:PATH=clang++ '-DCMAKE_C_FLAGS= ' '-DCMAKE_CXX_FLAGS= ' -DCMAKE_BUILD_TYPE:STRING=Debug -DLLVM_ENABLE_ASSERTIONS:BOOL=TRUE -DLLVM_TOOL_SWIFT_BUILD:BOOL=NO '-DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64' -DLLVM_INCLUDE_TESTS:BOOL=TRUE -LLVM_INCLUDE_DOCS:BOOL=TRUE -DCMAKE_INSTALL_PREFIX:PATH=/usr -DINTERNAL_INSTALL_PREFIX=local /home/src/swift/llvm
CMake Error at cmake/modules/CheckAtomic.cmake:36 (message):
Host compiler appears to require libatomic, but cannot find it.
Call Stack (most recent call first):
cmake/config-ix.cmake:296 (include)
CMakeLists.txt:403 (include)
-- Configuring incomplete, errors occurred!
See also "/home/src/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/CMakeFiles/CMakeOutput.log".
See also "/home/src/swift/build/Ninja-DebugAssert/llvm-linux-x86_64/CMakeFiles/CMakeError.log".
./utils/build-script: command terminated with a non-zero exit status 1, aborting
(gcc-4.8.2 was what I compiled llvm with)
libatomic is there:
$ locate libatomic
/opt/gcc-4.8.2/lib64/libatomic.a
/opt/gcc-4.8.2/lib64/libatomic.la
/opt/gcc-4.8.2/lib64/libatomic.so
/opt/gcc-4.8.2/lib64/libatomic.so.1
/opt/gcc-4.8.2/lib64/libatomic.so.1.0.0
I just don't know how to tell the build system where to look. I have tried the usual CMAKE_LIBRARY_PATH (exporting on the command line - I am not sure if cmake works like the way LD_LIBRARY_PATH, LIBRARY_PATH work) but it can't seem to find it.
I also don't have root on the machine.
I had not tried building from source on CentOS 6 until I saw this question, but I have been able to build Swift 2.2 on CentOS 7.1 and Ubuntu 14.04, with partial success. A few things to think about:
You will need numerous dependencies required to build Swift, and unless
they happen to be already on the system, you will need root access to
install them.
Use -R flag with the build-script to create a release build.
Building in DebugAssert (the default) will require a lot of memory. In my case even 14 GB was not sufficient. A release build
can be done with about 6 GB.
As for your specific problem, it is related to Clang's dependency on GCC-related packages for headers and libraries. See, for example, Fedora 21 with clang, without gcc.
Even if you installed GCC 4.8.2 and adjusted the path to use gcc and g++ from 4.8.2, Clang may still be looking in the old GCC directories for headers and libraries. CMake first tries to compile a C++ test file that includes the header atomic, which does not exist in the old GCC. So, it then tries to link a C test program that uses the library libatomic, which again doesn't exist in the old GCC. You can see this by looking at llvm/cmake/modules/CheckAtomic.cmake mentioned by usr1234567. CMakeError.log and CMakeOutput.log can also provide valuable insight. BTW, when I was building Swift on CentOS 7.1, I didn't run into this problem because GCC 4.8.2 was used by Clang for headers and libraries and the atomic header was found, so the C++ file got compiled. However, had the libatomic check been done, it would have failed, because libatomic.so in the repository-provided 4.8.2 has INPUT ( <name of some non-existent file> ), so trying to link with libatomic errors out.
I'm sure there are various ways of dealing with this issue, but what solved the problem for me was setting the following environment variables, please adjust to your specific setup:
export CPLUS_INCLUDE_PATH=/opt/gcc-4.8.2/include/c++/4.8.2:/opt/gcc-4.8.2/include/c++/4.8.2/x86_64-unknown-linux-gnu
export LIBRARY_PATH=/opt/gcc-4.8.2/lib64:/opt/gcc-4.8.2/lib/gcc/x86_64-unknown-linux-gnu/4.8.2
Also make sure that your 4.8.2 version of libstdc++.so is available to the dynamic linker at runtime. Since you don't have root, do
export LD_LIBRARY_PATH=/opt/gcc-4.8.2/lib64
If you had root, you could use ldconfig.
Before you start building Swift, you may want to try building, using Clang, a simple C program linking it with libatomic (the code doesn't actually have to use any symbols from the lib) and a simple C++ program that includes the <atomic> header. When compiling the C++ program, use the -std=c++11 compiler flag. If the C++ program compiles successfully, then it is not necessary for the libatomic linking test to be successful.
Interestingly, the CMakeOutput.log file still did not report finding GCC 4.8.2 as a candidate GCC installation, but the configuration/build worked well past the error.
Hopefully this helps. Please let us know if you run into something else.
CheckAtomic.cmake seems to be part of LLVM. I found a file at Github and it tries to find '__atomic_fetch_add_4' from libatomic
check_library_exists(atomic __atomic_fetch_add_4 "" HAVE_LIBATOMIC)
This fails for you. Check CMakeFiles/CMakeError.log to get more details why this test failed. Or try this line in a new project.

MATLAB can't see my C compiler to mex svmlib

I have 64-bit Mac, OS X 10.8.5, and I have xcode installed. I can also verify gcc works from the command line. When I type mex -setup I get
The options files available for mex are:
1: /Applications/MATLAB_R2013a.app/bin/mexopts.sh :
Template Options file for building MEX-files
0: Exit with no changes
This is unhelpful. And when I type make, with all of the relevant libsvm files in my folder of choice, I get
make
xcodebuild: error: SDK "macosx10.7" cannot be located.
xcrun: error: unable to find utility "clang", not a developer tool or in PATH
mex: compile of ' "libsvmread.c"' failed.
If make.m fails, please check README about detailed instructions.
Is anyone able to help me with this?
The quickest thing is to edit the mexopts.sh file directly, using your favorite text editor (you may need to do this with "Administrator Privileges"). The file:
/Applications/MATLAB_R2013a.app/bin/mexopts.sh
defines a bunch of paths and flags for invoking the C/C++ compiler on your system. It tends not to keep up with revisions to the MacOS.
On my system, I had to make the following changes:
lines 258-260
CC='gcc'
SDKROOT='/Developer/SDKs/MacOSX10.6.sdk'
MACOSX_DEPLOYMENT_TARGET='10.6'
line 273
CXX=g++
There will be many references to "CC=" in the file; you're looking for the ones that follow the line
maci64)
But the correct values for your system depend on which gcc/g++ you have and where they are installed. As you can see, I have the MacOS 10.6 Developer tools installed under /Develop. You will need an install of the Developer tools (XCode) - see
How to use/install gcc on Mac OS X 10.8 / Xcode 4.4
In more recent versions of the XCode tools, the path might look more like:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
But compiling MEX code with more recent versions of XCode might cause other problems - I had issues with char16_t, see:
MEX compile error: unknown type name 'char16_t'

Using clang++ for code analysis in an Autotools project in Eclipse

I am using Eclipse 4.2 on Mac OS 10.8, with the command line tools (Xcode 4.6.3) installed. The clang compiler supports C++11 by means of using the following flags: -std=c++11 -stdlib=libc++.
I have an Autotools-managed project in Eclipse. Real compilation works as expected after overriding CXX and CXXFLAFGS environment variables when configure is called. However, the static code analysis in Eclipse continues to use GCC (the version installed with Xcode is GCC 4.2), so there is no support for C++11, and lots of lines display errors that are not real ones, making static code analysis almost useless.
Using homebrew I also installed GCC 4.7, but I have not succeeded to make Eclipse use that version (or clang++) for performing static code analysis.
Is it possible, when using an Autotools-managed project, to make Eclipse use a different compiler for the static code analysis? Where should I specify that?
After installing Xcode 5, and following the directions in this question, I managed to solve the problem (I cannot test anymore whether this applies to Xcode 4.6 too).
The solution is to go to Project properties -> C/C++ General -> Preprocessor Include Paths, Macros etc. -> Providers -> CDT GCC Built-in Compiler Settings, and in Command to get compiler specs: append -std=c++11 -stdlib=libc++.
After doing that change, the line should look like:
${COMMAND} -E -P -v -dD ${INPUTS} -std=c++11 -stdlib=libc++