Travis-CI - configure LLVM - llvm

Is there any guide how to configure the .yml file on the Travis to get the LLVM >= 3.8?
This is the part of the Makefile that I'm using to compile my program:
all: program
OBJS = obj1.o obj2.o obj3.o obj4.o
CPPFL = `llvm-config --cppflags` -std=c++11
LDFL = `llvm-config --ldflags` -lpthread -ldl -lz -lncurses -rdynamic
LIBS = `llvm-config --libs`
program: $(OBJS)
g++ -o $# $(OBJS) $(LIBS) $(LDFL)
%.o: %.cpp
g++ -c $(CPPFL) -o $# $<
Thanks in advance.

This is still an open issue.
The most relevant examples I could find to help are this and this.
So yeah, you basically need to set up the specific toolchain yourself on the Travis VM.
PS: I could have added this as a comment, but not enough rep :S

Related

Unrecognized command line option ‘-mwindows’

I am trying to cross compile my hello world app on C from Ubuntu linux for Windows platform. So, to compile the app I am using this Makefile:
CC = g++
IDIR = -Iinclude
SRC = src
CFLAGS = -Wall -Wextra
LFLAGS = -mwindows
main.out: main.o
$(CC) $(CFLAGS) $(IDIR) $(LFLAGS) $^ -o $#
main.o: $(SRC)/main.c
$(CC) $(CFLAGS) $(IDIR) -c -o $# $^
As the result of cmmand make -f windows.mk I have such error:
g++: error: unrecognized command line option ‘-mwindows’
I have already tried gcc and g++. Is there way to compile it without making my own crosscompiler?
To cross compile for windows you would need mingw-w64 or use i686-w64-mingw32-g++
sudo apt-get install mingw-w64 For more info :
https://arrayfire.com/cross-compile-to-windows-from-linux/
Thanks a lot #HolyBlackCat
I've tried to using x86_64-w64-mingw32-g++ instead of just g++ or gcc without -mwindows and it succeed.

How can I compile a 32 bit program using a makefile

I'm attempting to make 3 separate programs mem_1.exe, mem_2.exe and mem_3.exe. I need to make them 32 bit when I compile them and the error message does not seem to be reflecting what I am writing. Below is my makefile.
mem_1: memlayout.o mem_1.o
gcc -o mem_1 memlayout.c mem_1.c -ldl -m32
mem_2: memlayout.o mem_2.o
gcc -o mem_2 memlayout.c mem_2.c -m32 -ldl
mem_3: memlayout.o mem_3.o
gcc -o mem_3 memlayout.c mem_3.c -m32 -ldl
mem_1.o: mem_1.c
gcc -c -o mem_1 mem_1.c -m32
mem_2.o: mem_2.c
gcc -c -o mem_2 mem_2.c -m32
mem_3.o: mem_3.c
gcc -c -o mem_3 mem_3.c -m32
memlayout.o: memlayout.c
gcc -c -o memlayout memlayout.c -m32
clean:
rm -f mem_1.o mem_2.o mem_3.o memlayout.o *~
Everytime I attempt to run this makefile I get this error message
cc -c -o memlayout.o memlayout.c
cc -c -o mem_1.o mem_1.c
gcc -o mem_1.exe mem_1.o memlayout.o -m32 -ldl
/usr/bin/ld: i386:x86-64 architecture of input file `mem_1.o' is incompatible with i386 output
/usr/bin/ld: i386:x86-64 architecture of input file `memlayout.o' is incompatible with i386 output
Which doesn't seem to make sense since I am using the -m32 flag to make it a 32 bit. Can anyone explain what I'm doing wrong?
I'd advise thinking of your makefile as code (since it is) and follow the standard advice to avoid repeating yourself.
It looks like you also have the flags a bit wrong. -m32 is a compiler flag. -ldl is a linker flag. If you're going to build for 32 bits, you need to tell both the compiler and the linker to built 32-bit files. No guarantee, but I think you want something on this general order:
CFLAGS = -m32
LFLAGS = -melf_i386 -ldl
mem_1: mem_1.o memlayout.o
$(LD) $(LFLAGS) -o mem_1 mem_1.o memlayout.o
mem_2: mem_2.o memlayout.o
$(LD) $(LFLAGS) -o mem_2 mem_2.o memlayout.o
mem_3: mem_3.o memlayout.o
$(LD) $(LFLAGS) -o mem_3 mem_3.o memlayout.o
# You probably don't really need this--`make` will usually have it built-in:
.c.o:
$(CC) -c $(CFLAGS) $<
Note: I'm old, so this is a sort of old-fashioned Makefile. Gnu recommends doing things a bit differently, but this should still work.

SDL Max OSX via Homebrew, Makefile not quite working

I have installed SDL through homebrew, and it works perfectly with my test program if I enter the following command directly in the terminal:
g++ -O3 -g -Wall -Wextra -std=c++1y hello.cpp hello_main.cpp `sdl2-config --cflags --libs` -o hello
but unfortunately my attempts to write a makefile (I will definitely need one) have yielded unsuccessful/unexplained results.
I am following this, but my configuration is different/I am not specifying Cocoa (I don't need to) so I expect that the issues I am encountering are probably due in part to my different requirements:
Compiling SDL on OS X with makefile
Example:
CC=g++
CFLAGS=-c -Wall
SDLFLAGS=`sdl-config --cflags --libs` -framework Cocoa
SOURCES=main.cpp Game.cpp IO.cpp Board.cpp Pieces.cpp Piece.cpp
OBJECTS=$(SOURCES:.cpp=.o)
EXECUTABLE=tetris
all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(OBJECTS) $(SDLFLAGS) -o $#
.cpp.o:
$(CC) $(CFLAGS) $< -o $#
clean:
rm -rf *.o $(EXECUTABLE)
My makefile so far:
CXX = g++
CXXFLAGS = -c -O3 -g -Wall -Wextra -std=c++1y
SDLFLAGS = `sdl2-config --cflags --libs`
SOURCES = hello_main.cpp hello.cpp
OBJECTS = $(SOURCES:.cpp=.o)
EXECNAME = hello
all: $(SOURCES) $(EXECNAME)
$(EXECUTABLE): $(OBJECTS)
$(CXX) $ (OBJECTS) $(SDLFLAGS) -o $#
.cpp.o:
$(CXX) $(CXXFLAGS) $< -o $#
clean :
-rm -f *.o *.core $(EXECNAME)
In my .hpp header file if I #include <SDL.h> and run the one-liner command, everything is successful. If I try my makefile above, cannot be found, but if I then change the directive into #include <SDL2/SDL.h> the library is discovered. Yet the console output is the following:
g++ -c -O3 -g -Wall -Wextra -std=c++1y hello.cpp -o hello
which is odd.
Running ./hello yields a "permission denied" error, which confirms that the linking and compilation were not successful.
Everyone's system is a little bit different and the questions I've found so far don't help in this case.
I am very close to having this working (but then again, how would I start using this in an IDE? I suppose that as long as I can import the fixed makefile or build from the terminal/edit only from the IDE, I am fine.)
What changes in the makefile do I need to make?
Thank you.
EDIT:
Variation 1:
CXX = g++
CXXFLAGS = -O3 -g -Wall -Wextra -std=c++1y -c
SDLCFLAGS = `sdl2-config --cflags`
SDLLIBFLAGS = `sdl2-config --libs`
SOURCES = hello_main.cpp hello.cpp
OBJECTS = $(SOURCES:.cpp=.o)
EXECNAME = hello
all: $(SOURCES) $(EXECNAME)
$(EXECUTABLE): $(OBJECTS)
$(CXX) $ (OBJECTS) $(SDLLIBFLAGS) -o $#
.cpp.o:
$(CXX) $(CXXFLAGS) $(SDLCFLAGS) $< -o $#
clean :
-rm -f *.o *.core $(EXECNAME)
I chatted with a friend and figured what was wrong: a bunch of typos and rule oddities. The following works, for anyone out there who needs a basic makefile:
CXX = g++
CXXFLAGS = -O3 -g -Wall -Wextra -std=c++1y
#LDFLAGS = -lSDL2_image
SDLCFLAGS = $(shell sdl2-config --cflags)
SDLLIBFLAGS = $(shell sdl2-config --libs)
SOURCES = hello_main.cpp hello.cpp
OBJECTS = $(SOURCES:.cpp=.o)
EXECNAME = hello
all: $(EXECNAME)
$(EXECNAME): $(OBJECTS)
$(CXX) $(OBJECTS) $(SDLLIBFLAGS) $(LDFLAGS) -o $#
%.o: %.cpp
$(CXX) -c $(CXXFLAGS) $(SDLCFLAGS) $< -o $#
clean :
-rm -f *.o *.core $(EXECNAME)
You should split your sdl2-config into two - as there are two steps. sdl2-config --cflags should go in the compiler step - thats is the .cpp:.o line in your example. The linking step should be sdl2-config --libs then. The second one seems fine for your case, the additional --cflags there does no harm but is not required.

Makefile without specifying the source file

I have a makefile as follows:
# Makefile for VocabLearn
MACHTYPE=$(shell uname -m)
GCC = g++
CC=gcc
# OPTFLAGS=-g2
OPTFLAGS=-O3 -ffast-math -Wall -mfpmath=sse -msse2 -funroll-loops -march=core2
OTHERFLAGS=-Wall -fopenmp
INCLUDE_PATH=-I../lib/ann_1.1/include/ANN -I../lib/ann_1.1_char/include/ANN \
-I../lib/imagelib -I../VocabLib -I../lib/zlib/include
LIB_PATH=-L../lib -L../VocabLib -L../lib/zlib/lib
OBJS=VocabLearn.o
LIBS=-lvocab -lANN -lANN_char -limage -lz
CPPFLAGS=$(INCLUDE_PATH) $(LIB_PATH) $(OTHERFLAGS) $(OPTFLAGS)
BIN=VocabLearn
all: $(BIN)
$(BIN): $(OBJS)
g++ -o $(CPPFLAGS) -o $(BIN) $(OBJS) $(LIBS)
clean:
rm -f *.o *~ $(LIB)
When I 'make' it in the prompt, it works fine and output the following info:(I use Mac OS, c++ means clang compiler)
c++ -I../lib/ann_1.1/include/ANN -I../lib/ann_1.1_char/include/ANN
-I../lib/imagelib -I../VocabLib -I../lib/zlib/include -L../lib -L../VocabLib -L../lib/zlib/lib -Wall -fopenmp -O3 -ffast-math -Wall -mfpmath=sse -msse2 -funroll-loops -march=core2 -c -o VocabLearn.o VocabLearn.cpp
g++ -o -I../lib/ann_1.1/include/ANN -I../lib/ann_1.1_char/include/ANN
-I../lib/imagelib -I../VocabLib -I../lib/zlib/include -L../lib -L../VocabLib -L../lib/zlib/lib -Wall -fopenmp -O3 -ffast-math -Wall -mfpmath=sse -msse2 -funroll-loops -march=core2 -o VocabLearn VocabLearn.o -lvocab -lANN -lANN_char -limage -lz
I just want to know how this makefile works. As you can see, since this makefile doesn't specify which source code to compile, how does the compiler know it is 'VocabLearn.cpp' that it should process? (My guess is that it will search source file according to the name of the object file, VocabLearn.o) Also this line seems a bit strange for me:
g++ -o $(CPPFLAGS) -o $(BIN) $(OBJS) $(LIBS)
Why is there a '-o' before '$(CPPFLAGS)'?
This makefile is using implicit rules to compile the source files. The rule:
$(BIN): $(OBJS)
asks for the object files in OBJS, and make already knows how to build VocabLearn.o if there is a file VocabLean.cpp.
Basically there is an implicit rule to convert *.cpp files to *.o files, however you have to have *.o as a dependency in one your targets. In the given Makefile, you have VocabLearn.o as a dependency for $(BIN). So, VocabLearn.o gets auto-generated from VocabLearn.cpp file.

Ubuntu 12.10 - Cannot find -ltcl when I compile my C++ program

I am working on a C++ project and I need to use libtcl.
I am running Ubuntu 12.10 32bits and there is a problem when I try to compile my files :
g++ -o executable executable.o -L/usr/share/tcltk -lncurses -ltcl
/usr/bin/ld: cannot find -ltcl
libncurses is found but not libtcl...
Do you have any idea?
I have seen that libtcl8.4.so.0 libtcl8.5.so.0 exist in /usr/lib
The makefile that I am using looks like this :
CC = g++
CFLAGS = -g
LDFLAGS =
EXEC = executable
LIB = -L/usr/share/tcltk -lncurses -ltcl
all: executable
executable: executable.o
$(CC) $(LDFLAGS) -o $(EXEC) executable.o $(LIB)
executable.o: executable.cpp
$(CC) $(CFLAGS) -c executable.cpp
clean:
rm -f executable executable.o
Thanks
(Answered in a comment. See Question with no answers, but issue solved in the comments (or extended in chat) )
#soon wrote:
just create symlink to the your library like so #ln -s /usr/lib/libtcl8.5.so.0 /usr/lib/libtcl.so