I built clang using VS2013 and then ran it from the command line with a -v option (clang -v testfile.c). Among the things it reported was:
#include <...> search starts here:
C:\Program Files (stand-alone)\LLVM\bin..\lib\clang\3.7.0\include
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include
I don't understand why it is even looking at the Microsoft headers in the first place. I do not have an environment variable named INCLUDE. I verified this by doing "set INCLUDE" from the command line getting a message saying there was no such environment variable. So, where and why is clang getting this information and how do I stop it? During the compile several warnings (not errors) occur regarding some of the things in Microsoft header files too.
The version it reports is:
clang -cc1 version 3.7.0 based upon LLVM 3.7.0svn default target i686-pc-windows-msvc
I understand the i686-pc-windows part, but why the msvc part? If that means it was built with msvc then that makes sense, but if it means that clang was built to run with msvc support, I don't understand why.
Related
I've been trying to use emscripten to build C into WASM and Javascript. Emscripten requires clang so I installed it but then it says "emcc: error: llc executable not found at C:\Program Files\LLVM\bin\llc.exe" when running emcc and em++. Is there a reason that LLC.exe is missing in the windows version? If so how do I get it.
llc is a developer tool. If you want it, build it from llvm-project source. This is/will not included in the release binary.
A couple of days ago I have started to migrate my CMake-based C++ library project from Travis CI to GitHub Actions. I immediately ran into trouble with the windows-latest runner (link to runner specs). After many wasted hours I tracked down the issue to the Windows SDK that CMake selects when it generates the build system.
On a local VM where I tried to replicate the runner environment CMake always selects the SDK version 10.0.18362.0, because no other SDK is installed on that system. On the runner system, though, there seem to be several SDKs installed (cf. the runner specs), and CMake by default selects SDK version 10.0.17763.0.
The actual problem: With 10.0.17763.0 selected, as soon as the first file is being compiled the compiler starts spewing out C5105 warnings like the following (line breaks added by me for better readability):
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\corecrt_search.h(188,5):
warning C5105: macro expansion producing 'defined' has undefined behavior
[D:\a\libsgfcplusplus\libsgfcplusplus\build\src\libsgfcplusplus_shared_objects.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\ucrt\stdlib.h(79,5):
warning C5105: macro expansion producing 'defined' has undefined behavior
[D:\a\libsgfcplusplus\libsgfcplusplus\build\src\libsgfcplusplus_shared_objects.vcxproj]
[...]
Eventually there are also errors which cause the build to fail. The first of these errors is this:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.17763.0\um\oaidl.h(487,17):
error C2059: syntax error: '/'
[D:\a\libsgfcplusplus\libsgfcplusplus\build\src\libsgfcplusplus_shared_objects.vcxproj]
When I force CMake to use a different SDK, by setting CMAKE_SYSTEM_VERSION to 10.0.18362.0, all problems go away and the build works fine.
Before I go down that road of forcing CMake to do something it doesn't want to do, I wanted to ask for advice if someone can recommend a better approach?
Also of interest would be if someone could explain what's actually going on here? How is it possible that MSVC has problems parsing Microsoft's own system header files when using one SDK version, and no problem at all when using another SDK version? Link to a build log in case someone is interested, but this might go away soon when I delete the branch.
In the meantime I managed to reproduce the problem on my local VM by installing the component "Windows 10 SDK (10.0.17763.0)" in the Visual Studio Installer. On the VM CMake still defaults to 10.0.18362.0, but when I force it to use 10.0.17763.0 like this
cd build
cmake -DCMAKE_SYSTEM_VERSION="10.0.17763.0" ..
then I get the same build failure as on the Github Actions runner. At least I can now say that it's not the Github Actions runner that is at fault.
On the other hand I also can't see how my project should be the culprit. I certainly don't do anything special that should make the project build with one Windows SDK, but not with the other.
Lacking the time (and the will) to further investigate the issue, for the moment I decided to follow the path of least resistance and am now building with these lines in the project's build.yml:
cd build
cmake -DCMAKE_SYSTEM_VERSION="10.0.18362.0" ..
cmake --build . --config Release
I'm attempting to use OpenCV for Windows as supplied by opencv.org in a project I'm building with JetBrains' CLion IDE. I've installed the opencv library and configured CLion (set(OpenCV_DIR) to reference the build directory under it, but CMake issues the warning:
Found OpenCV Windows Pack but it has no binaries compatible with your configuration.
You should manually point CMake variable OpenCV_DIR to your build of OpenCV library.
I've tried some of the older distributions from opencv.org with the same results. It appears CMake is locating the OpenCV libraries, but doesn't want to use them. Why, and how do I get the OpenCV libraries to work under CLion?
The short answer is, you will probably need to build OpenCV from source in order to use it with CLion. But given the number and range of partially answered and unanswered questions here* and elsewhere on using JetBrains' CLion IDE with the OpenCV library, I think an overview is needed (my notes are from CLion 2016.3 and OpenCV 3.1, YMMV):
Though not produced by JetBrains, CMake is very central to CLion's operation. Understanding CMake therefore helps greatly in diagnosing CLion build problems. In particular CMake maintains a disk "cache" of settings which you may need to clear to incorporate changes to your environment (Tools->CMake->Reset Cache and Reload Project).
To make use of OpenCV in your build you must specify it in your project's CMakeLists.txt file. You request that CMake locate your OpenCV location and link it to your TARGET. An example of a sequence of commands from CMakeLists.txt for an executable named mushroom follows:
add_executable(mushroom ${SOURCE_FILES})
FIND_PACKAGE(OpenCV REQUIRED)
TARGET_LINK_LIBRARIES(mushroom ${OpenCV_LIBS})
(For more on FIND_PACKAGE, see CMake:How To Find Libraries.)
FIND_PACKAGE for package XXX works either by way of FindXXX.cmake files located at CMake's Modules directory, or by consulting environment variable XXXX_DIR. On my system, no FindOpenCV.cmake file was present, so I relied on the OpenCV_DIR environment variable instead. This must be set, not to the root of your OpenCV installation, but to the build folder beneath it. I used an entry in CMakeLists.txt to set this variable, e.g.:
set(OpenCV_DIR C:/Users/myacct/AppData/Local/opencv-3.0.0/build)
To link with OpenCV, CMake uses either FindOpenCV.cmake or OpenCV_DIR (see previous point above) to locate a file named OpenCVConfig.cmake. This file is generated by and ships with a particular build of OpenCV in order to document what components are present and where they are located.
Problems may occur when variable names used by OpenCVConfig.cmake conflict with those CLion has stored in its environment. In particular, if your OpenCV was built by Microsoft Visual C (MSVC), as is the Windows distribution from opencv.org, it won't work with CLion.
Because CLion's build toolchain (ControlAltS-toolchain) uses either MinGW or Cygwin, OpenCVConfig.cmake will search for OpenCV binaries under a subdirectory named mingw or cygwin and will find none because the binaries were built with MSVC (it will look in a directory like vc11 or vc12 instead). This probably means you will need to build OpenCV from source in order to use it with CLion.
Would reconfiguring OpenCVConfig.cmake to point to the MSVC binaries make this work? you may ask. Unfortunately the answer is still no, because libraries built with one compiler typically cannot be linked with another one.
OpenCVConfig.cmake or FindOpenCV.cmake likely contain diagnostic messages, but when CLion executes CMake for you, message(STATUS) calls are not displayed. To make them display, change them to message(WARNING) or message(FATAL_ERROR). But CLion 2016.3 EAP relieves this problem; see https://stackoverflow.com/a/39398373/5025060.
CLion does not indicate which .cmake script issued which diagnostics; don't assume they all come from the same script.
Hopefully this provides some general guidance on resolving CLion / CMake / OpenCV compatibility problems. Note that this does not cover compiler or linker issues; these will not appear until CMake completes its initial makefile build. Compiler or linker issues occur at a later stage and are controlled by include*(), link*() and other commands in CMakeLists.txt.
*Some related SO questions:
OpenCV Windows setup with CLion
OpenCV CLion (Cmake) linking issue - cmake reports a strange error
use OpenCV with Clion IDE on Windows
Compiling OpenCV on Windows with MinGW
Could not find module FindOpenCV.cmake ( Error in configuration process)
CMake: Of what use is find_package() if you need to specify CMAKE_MODULE_PATH anyway?
After breaking out the troubled command :
/usr/jdk/jdk1.5.0_07/bin/java -Dant.home=. -cp $CLASSPATH:./build/classes org.apache.tools.ant.Main -emacs bootstrapI got the error:
BUILD FAILED
Could not load the version information
Before breaking out the above commad line I ran a complete ./build.sh and ./build install command and got:
Buildfile: build.xml
bootstrap:
prepare:
check_for_optional_packages:
build:
Created dir: /export/home/rs841k/tmp/apache-ant-1.6.0/build/lib
Compiling 233 source files to /export/home/rs841k/tmp/apache-ant-1.6.0/build/cla
sses
javac:
Does anyone have any idea what is happening here and how to resolve it?
This is happening: You're passing source and target parameters to javac. Source seems to be 1.5, and target 1.1. This is a combination that is not allowed. The compiler does not know how to build JVM-1.1-compatible byte code from your sources, which might use 1.5-specific features.
This Oracle article explains the details:
javac does not accept a target (or compilation strategy) lower than the source language it is configured to accept. Each new version of the source language is generally accompanied by a new ClassFile version that allows the ClassFile to give meaning to new bytecode instructions, flags, and attributes. Encoding new source language constructs in older ClassFile versions is likely to be difficult. How would javac encode annotations from the Java 1.5 source language without the Runtime[In]Visible[Parameter]Annotations attributes that appeared in the 49.0 ClassFile?
I am using open source C++ library DCMTK from http://dicom.offis.de/dcmtk.php.en.
I have successfully compiled this library on Windows using VC++ IDE, MacOS Xcode, Mac iOS simulator.
But I am not able to compile this library on iOS device as it is ARM based architecture.
DCMTK library compiled very well on Intel architecture.
Now my problem statement is :-
I need to compile this DCMTK C++ library on ARM architecture by cross compilation.
I am using Ubuntu 64 bit machine for cross compilation.
I have installed binaries from GNU ARM tool chain from http://www.gnuarm.com/
I am using GCC toolchain 4.0 binutils-2.16.1, gcc-4.0.2-c-c++, newlib-1.14.0, insight-6.4, TAR BZ2 [65.5MB] binaries for Ubuntu 64 bit machine for ARM cross compilation.
After Installing these binaries on Ubuntu I have set PATH environment variable to
PATH=$PATH/gnu_arm/bin
For configuring the DCMTK C++ library I have run the following command on shell
CC=arm-elf-gcc CXX=arm-elf-g++ AR=arm-elf-ar RANLIB=arm-elf-ranlib ARFLAGS=cruv ./configure –prefix=$home_dicom –target=arm-elf –host=arm-elf –enable-std-includes –disable-threads
It creates a make file properly. Now I am trying to compile the code by using make command, but facing so many compilation errors like :-
1) I tried to compile my first dependent C++ library that is ofstd.
I got error for DIR*, struct dirent, opendir(), closedir() calls.
It includes for these calls, but I did not found any definitions for the above calls in this header file.
2) When I compile another library oflog I got the following errors like
error: nthos was not declared in this scope
error: ntohl was not declared in this scope
error: htons was not declared in this scope
error: htonl was not declared in this scope.
These calls are networking calls and are not defined in any of the header file from GNU ARM tool.
I tried to download the sources of ARM binaries and extracted the tar files and try to copy missing header files to installed GNU ARM on Ubuntu.
For some files it compiles after doing changes to copied header files, and for some again it gives compilation errors.. There is a loop of compilation errors for every file present under DCMTK library as some of the standard header files are missing.
Please suggest if there is any other tool chain available for ARM cross compilation on Ubuntu 64 bit machine.
Or any other good solution apart from this.
Thanks!!!
Amit
There are many areas for problems when it comes to cross compiling. There are three main flags for cross compiling. -host , -target, and -build. The -host flash is the machine in which the resulting binaries will run on. The -build flash is the system in which you will be compiling on. The -target flag is for building libraries that will be used in cross compiling. So if you were to build your own gcc tool chain. So in your case you won't set the target flag as we're not building a tool chain. the -host flag will be arm-elf. And the -build flag will be amd64.
Usually a cross compilation fails if there are inconsistencies between the regular c compiler and the cross compiler. I have compiled several libraries for the avr32 with a toolchain generated by buildroot, but in some cases (socat project for example) it hasn't been possible.
Your host, your target and the CXX flags look ok. I think it is not necessary to put the AR flag (that is the idea with the host and target option).
In other hand, this is an example for the expat libraries for the avr32:
./configure --host=avr32-linux --prefix=/home/juan/builds/build_expat/ CC=avr32-linux-gcc
make; make install
I can recommend you that tries to cross compile from an ia32 architecture. I had several problems with that ubuntu in the past.