I am starting in the world of LLVM and searched in several places and read several documentation about LLVM but I found nothing showing how to compile a program that uses LLVM headers and libs ....
I wrote this simple program just to try to compile, using the Visual Studio cross-compiler, I tried several command line options .... even using the -lLLVM option, but, nothing worked ...
I tried using g++ and clang++
#include <iostream>
#include <llvm/ADT/OwningPtr.h>
#include <llvm/Support/MemoryBuffer.h>
int main()
{
llvm::OwningPtr<llvm::MemoryBuffer> buffer
return 0;
}
When I try to build, I get this erro:
error : 'llvm/ADT/OwningPtr.h' file not found
So, what is the command line to compile this simple program?
The command llvm-config --cxxflags --ldflags --system-libs --libs core will provide you with all the linkable llvm libraries, provided you have llvm installed. Just link with this command in single quotes
Related
I am running clang-tidy checks using cmake version 3.20.0-rc1 on Windows 10.
My project builds using GNU 8.3.0.
Sadly I get the error
error: 'cstddef' file not found [clang-diagnostic-error]
#include <cstddef>
clang-tidy info:
LLVM (http://llvm.org/):
LLVM version 12.0.0
Optimized build.
Default target: i686-pc-windows-msvc
Host CPU: skylake
[clang-diagnostic-error] is basically a compiler error coming from the clang backend.
Clang-tidy needs an AST (abstract syntax tree) - your code has to be compileable by clang compiler in order to generate an AST. Only then will clang-tidy analyze your code.
Get your code to compile by clang instead of GCC and you should find the source of your problem.
I am trying to compile OpenCV3 and put it into Qt project because Qt officially provides MinGW Version, so I didn't use MinGW-w64.
I enabled ENABLE_CXX11 and disabled ENABLE_PRECOMPILED_HEADERS in CMake.
Now the problem is MinGW does not contain std::thread.
I know the mingw-std-threads lib can fix it. but I don't want to modify OpenCV source code. Is there any other way to adding c++ thread feature to MinGW? or tell OpenCV using pthread by CMake?
BTW. I don't want use Qt's MinGW because I think using official MinGW to compile the lib shall be used in any version of Qt.
Update:
In OpenCV detection_based_tracker.cpp, there is a CV_CXX11 Marco choice to the using std thread or the pthread. But I didn't see anywhere define CV_CXX11.
Is part of detection_based_tracker.cpp code:
#ifdef CV_CXX11
#define USE_STD_THREADS
#endif
#ifdef USE_STD_THREADS
#include <thread>
#include <mutex>
#include <condition_variable>
#else //USE_STD_THREADS
#include <pthread.h>
#endif //USE_STD_THREADS
My environment:
windows 7 64bit
cmake-3.10.1-win64-x64
opencv-3.4.0
gcc 6.3
What I tried:
install CMake and MinGW
disable ENABLE_PRECOMPILED_HEADERS in CMake-gui
comment #define USE_STD_THREADS in detection_based_tracker.cpp line 48
configure and generate Makefile
Run mingw32-make
it's successfully compiled, but I have to modify OpenCV source code.
If you use the right version of MinGW, namely MinGW-w64, most toolchains builds have the modern threading features available.
You can e.g. use the installer or install it through MSYS2.
I've been trying to use clang-analyze without issues for 2 days.
I am using the following command:
checker-276/scabuild xcodebuild -workspace App.xcworkspace -scheme AppScheme -configuration Debug clean build
scan-build: Using '/Users/abc/checker-276/bin/clang' for static analysis
Build settings from command line:
CLANG_ANALYZER_EXEC = /Users/abc/checker-276/bin/clang
CLANG_ANALYZER_OTHER_FLAGS =
CLANG_ANALYZER_OUTPUT = plist-html
CLANG_ANALYZER_OUTPUT_DIR = /var/folders/5p/48jf5v4516l7x9dhb0vj6jr0prj25r/T/scan-build-2015-03-06-113904-24636-1
RUN_CLANG_STATIC_ANALYZER = YES
I've tried to play with the parameters, to set the sdk, build settings, compiler etc, however the final result is the same:
mylib.h:68:10: fatal error: 'string' file not found
#include <string>
fatal error: 'vector' file not found
#include <vector>
I am using several c++ library which are included in .mm files. I think that could be a problem, but XCode static analyser can do the job right, so I assume that I can configure also clang static analyser in way to do the job.
xcodebuild does the hard work(compilation) anyway why does scanbuild fails then?
Do you have any idea how I can eliminate the above mentioned issues?
I appreciate any advice, thanks for your time spending with it!
I have a question relating to this question Unable to Compile Objective C using Gnustep on windows
I am trying to compile my first objective c app on Windows.
The file is hello.m (all files below created in Visual Studio)
#import <../Program Files/GNUstep/System/Library/Headers/Foundation/Foundation.h>
int main(int argc, const char* argv[])
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSLog(#"Hello from Hello.m!");
[pool release];
return 0;
}
In order to compile it I have a GNUmakefile in the same directory:
include $(GNUSTEP_MAKEFILES)/common.make
TOOL_NAME = hello
YourProg_OBJC_FILES = hello.m
include $(GNUSTEP_MAKEFILES)/tool.make
As I understand it, when I run make the command "make" the GNUmakefile will execute.
When I do this in the GNUStep shell I get an error
GNUmakefile:1 *** missing separator. Stop.
I tried adding a tab to the first line. This did nothing. Yes, I am sure it was a tab, not a space.
I Had the same problem. I used Notepad++ to make the GNUmakefile. My default encoding with Notepad++ is UTF8. But make.exe from MINGW32 seems to wait a file with ANSI encoding.
So, verify if your file is encoded with ANSI.
make is complaining about your makefile, so you probably have a syntax error somewhere.
See: http://www.gnu.org/software/automake/manual/make/Error-Messages.html:
This means that make could not understand much of anything about the makefile line it just read. GNU make looks for various separators (:, =, recipe prefix characters, etc.) to indicate what kind of line it's parsing. This message means it couldn't find a valid one.
Try you might try compiling directly:
gcc -o hello hello.m -I/c/GNUstep/GNUstep/System/Library/Headers \
-L /c/GNUstep/GNUstep/System/Library/Libraries -lobjc -lgnustep-base \
-fconstant-string-class=NSConstantString
you should never have to provide the full path for the Foundation.h header file.
It should always be #import <Foundation/Foundation.h>.
This together with your makefile problem indicate that something is not setup correctly on your machine.
Did you run the make command from an msys shell or from the Windows commandline?
If you chose to go with the Windows command line you will face some problems because the environment is not setup correctly there in contrary to the msys shell provided with the GNUstep installer.
If you want to run gcc manually on the other hand you can have a look at this SO answer.
In your GNUmakefile, YourProg_OBJC_FILES should be modified to be hello_OBJC_FILES, just like below
include $(GNUSTEP_MAKEFILES)/common.make
TOOL_NAME = hello
hello_OBJC_FILES = hello.m
include $(GNUSTEP_MAKEFILES)/tool.make
Or you can also just compile in command line like this
$ gcc `gnustep-config --objc-flags` hello.m -o hello `gnustep-config --base-libs`
The gnustep-config like pkg-config command can print out the compiling and linking options for gcc.
If I compile this QT c++ program in SuSE Linux
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
When I type
i386-mingw32-g++ helloworld.cpp
I get the following error
i386-mingw32-g++: error trying to exec 'cc1plus': execvp: No such file or directory
Is this because MinGW package which i installed contains only gcc in it.. hence i downloaded gcc-g++-3.4.5.rpm package and just copy pasted i386-mingw32-g++ and cc1plus executable along with C++ include files.
Pls reply.
Thanking You
Ugh. The cc1plus in gcc-g++-3.4.5.rpm is not for mingw32. You need the one for your distro.
e.g. for Fedora 10, use http://sourceforge.net/projects/outmodedbonsai/files/Mingw%20Cross-compiler/mingw-1.10-1.fc10.x86_64.rpm
Quoting from here:
It means that your shell could find
the g++ frontend of the GNU compiler
but that frontend couldn't find
cc1plus, the actual C++ compiler; it
could find cpp, the preprocessor, it
already ran. Go to the directory where
the g++ frontend is stored (type:
"which g++") and look for the file
cc1plus in that same directory or a
sub- directory thereof. If it isn't
there your compiler installation is
broken; if it is there some
configuration of it went berzerk.
Also, have a look at this thread.
suse cross-compile toolchain is here.
http://download.opensuse.org/repositories/CrossToolchain:/mingw/