I'm exploring right now open source tools to test my QT GUI Applications. After some research I found the promising:
TUG: GUI Unit Testing library https://github.com/pedromateo/tug_qt_unit_testing_fw
Unfortunately, it is a Linux library, but I'm developing windows applications with MSVC.
But I didn't gave up and installed Cygwin. My idea was to compile TUG with Cygwin and afterwards using it together with the cygwin1.dll in my testing framework.
TUG is being compiled using qmake Project files producing normal make files.
The first step was to include the switch -D__MINGW32__ in the DEFINES section of my qmake project file. This eliminates some compilation errors.
Then I ran my qmake with:
/cygdrive/[My Windows QMake Install Path]/qmake.exe –spec cygwin-g++ tug_base_lib
Then I ran make and it compiles fine, but failed in the last step linking the object files to the libTUG.dll. It ended up with a lot of undefined references errors.
My idea is, that make tries to link MSVC Windows Libraries to my libTUG.dll resulting in an error.
Does anyone has experience in using TUG together with Windows Applications?
The corresponding section in the generated Makefile, where the linking failed was probably:
$(TARGET): $(OBJECTS) $(SUBLIBS) $(OBJCOMP)
-$(DEL_FILE) $(TARGET) $(TARGET0) $(TARGET1) $(TARGET2)
$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS) $(OBJCOMP)
-$(QMAKE) -install ln -s $(TARGET) $(TARGET0)
-$(QMAKE) -install ln -s $(TARGET) $(TARGET1)
-$(QMAKE) -install ln -s $(TARGET) $(TARGET2)
where the Options where
LINK = g++
LFLAGS = -shared -Wl,-soname,libTUG.dll.1
LIBS = $(SUBLIBS) -L/usr/X11R6/lib -L[Path of my Windows QT Libs] -lQt5Widgets_vc14-x64 -lQt5Gui_vc14-x64 -lQt5XmlPatterns_vc14-x64 -lQt5Network_vc14-x64 -lQt5Test_vc14-x64 -lQt5Core_vc14-x64 -lGL -lpthread
TARGET = libTUG.dll.1.0.0
TARGETA = libTUG.a
TARGET0 = libTUG.dll
TARGETD = libTUG.dll.1.0.0
TARGET1 = libTUG.dll.1
TARGET2 = libTUG.dll.1.0
Related
I need to build a program on Windows, MacOS and Linux which relies on multiples dependencies. I tried to limit them as much as I could but I should ended up using WxWidgets, libcurl, openssl and libarchive.
I choose those dependencies because I must be able to:
compute a md5 hash (openssl)
decompress a zip archive (libarchive)
provide a GUI (WxWidgets)
use HTTPS (libcurl)
I am aware that this might be an overkill to import 5 libraries to only do those 5 things but I do not know any better solution yet. As I am writing this, I'm only using libcurl and openssl and building for Windows, MacOS and Linux is already very difficult for me.
I would like to distribute a standalone executable for each platform in addition to the source code, to build my project, I use the following Makefile :
CXX = g++
NAME = foo
SRC = $(wildcard src/*.cpp)
OBJ = $(SRC:.cpp=.o)
CXXFLAGS = -I./inc -std=c++11 -Wall -Wextra -Werror -g
all : $(NAME)
$(NAME) : $(OBJ)
$(CXX) $(CXXFLAGS) -o $# $^ -lcurl -lssl -lcrypto
clean :
rm -rf $(SRC:.cpp=.o)
fclean : clean
rm -rf $(NAME) test
re : fclean all
reclean : fclean all clean
.PHONY : all clean fclean re reclean
This worked great(even on Windows thanks to MSYS2 and MINGW) until I tried to statically linked each library to distribute a standalone binary :
$(NAME) : $(OBJ)
$(CXX) $(CXXFLAGS) -o $# $^ -lcurl -lssl -lcrypto
becamed
$(NAME) : $(OBJ)
$(CXX) $(CXXFLAGS) -o $# $^ libcurl.a libssl.a libcrypto.a
On Linux(Ubuntu 22.04), I downloaded curl and openssl source codes and built them using -static flags, copied the *.a inside my project's directory and I was done.
Now I'm trying to build curl and openssl on Windows with MSYS2, most of my attempts failed with error messages and took forever(> 30 minutes) to complete the build process. After struggling a little too much time, I finally managed to compile openssl by adding -lcrypto -lcrypt32..?
I do not think I will be able to finish this project with this "building process" as I still need to figure it out how build and link libarchive and WxWidgets. Is there anything I am missed out regarding the building process ? Should I pick others libraries ? Or It is just how it is ?
Thanks for your help.
In purpose of automatic tests for the project i need to convert visual studio vcxproj file to a makefile for it to be later compiled.
I have installed mingw on my laptop. Later took the most simple console application and created makefile for it.
EXECUTABLE=..\Debug\ConsoleApplication3.exe
CC=gcc
LINK=gcc
LDFLAGS=-lgdi32
src = $(wildcard *.cpp)
obj = $(src:.cpp=.o)
all: myprog
myprog: ConsoleApplication3.cpp
$(CC) -c ConsoleApplication3.cpp -o $(EXECUTABLE)
.PHONY: clean
clean:
del $(obj) $(EXECUTABLE)
It compiles and builds when i run the "make" utility but when i try to run it has an error:
"The version of this file is not compatible with the version of windows you are running. Check your computer's system information to see whether you need x86 or x64 version of the program."
How can i edit makefile to make it work?
I'm trying to compile C++ project with gcc-make command but program giving this error. I already compiled Crypto++ and added include and lib folder but I dont know how to add this dir to gcc.
What should I do for fixing this "-lcrytopp" error?
I'm using makefile and this is line of 33-34.
$(TARGET): build $(OBJECTS)
$(CC) $(OBJECTS) -o $(TARGET) -lcryptopp
Error:
D:\Osman\CnC RA2\Mix\ccmix-crypto\ccmix-crypto>make
g++ src/mix_db_gamedb.o src/mix_db_gmd.o src/mix_header.o src/mix_db_lmd.o
src/mixid.o src/ccmix.o src/mix_file.o -o build/ccmix -lcryptopp
c:/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../../mingw32
/bin/ld.exe: cannot find -lcryptopp
collect2.exe: error: ld returned 1 exit status
Makefile:34: recipe for target 'build/ccmix' failed
make: *** [build/ccmix] Error 1
Crypto++ directory:
Compile error:
You haven't added the directory containing the library to your link line. It should be something like -Lxxx where xxx is the path to the directory containing the cryptopp library:
$(TARGET): build $(OBJECTS)
$(CC) $(OBJECTS) -o $(TARGET) -Lxxx -lcryptopp
(replace xxx with the directory containing the cryptopp library)
What should I do for fixing this "-lcrytopp" error?
When working from the Crypto++ build directory on Unix compatibles, the project does not use include and lib (as your picture shows). Everything is placed in the root directory (as your picture shows).
If you perform a make install, then the directories are setup, but it appears you did not install. I should also say that MinGW is not usually tested anymore because the project is abandoned, so I'm not sure where make install actually installs to on MinGW.
To fix the compile error, tweak your make recipe:
$(TARGET): build $(OBJECTS)
$(CXX) $(CXXFLAGS) -I. $(OBJECTS) ./libcryptopp.a -o $(TARGET)
The recipe above uses CXX (C++ compiler) rather than CC (C compiler); it uses CXXFLAGS (which should be something like -DNDEBUG -g2 -O2); it calls out the header path (-I.); and it links to the static library (./libcryptopp.a). Linking to the static library will avoid your next set of problems.
You can follow MadScientist's advice and use -LXXX and -lcryptopp. You might even add a runpath with -Wl,-rpath,D:\Osman\CnC RA2\Mix\ccmix-crypto\ccmix-crypto. But at the end of the day, using -L and -l causes a fair amount of trouble. Avoid the future problems by statically linking libcryptopp.a.
Also see GNUmakefile | Compiling and Linking on the Crypto++ wiki.
Your fist picture shows ipch and Win32 directories. That usually means you built the Crypto++ library with Visual Studio. Now you are building a program with GCC. You should not mix and match compilers like that. Nothing good will come of it.
So I'm on Windows, and I'm wondering how to build a DLL and a Static Library in MingW, and in different architectures like x86 and x64. I'm new to MingW, but not C++. I've been looking around Google a while and haven't found a way to do it yet, the reason being is because most of the tutorials I find are out-of-date.
GNU 'Make' File
Sources = Test.cpp Utilities.cpp
Objects = $(Sources:.cpp=.o)
ProjName = MyProgram
BuildName = $(ProjName).dll
$(ProjName) : $(Objects)
g++ -o $(BuildName) $(Objects)
$(Objects) :
g++ -c -D TEST_DYNAMIC $(Sources)
Clean :
rm $(Objects) $(BuildName)
Addition Information
Mingw Version: 4.8.1-4
Attempts
http://www.mingw.org/wiki/sampledll
-shared is an unrecognized command.
Okay so I figured out why it wasn't working. Those sites are not out-of-date, my MingW was, but my system was using Cygwin, which is what I don't want. So I changed my 'Path' variable to direct it to the correct Mingw.
I have a project of multiple source and header files and I wrote my own Makefile by specifying the required external libraries and headers (the directory containing the OpenCV header files and the directory containing the OpenCV libraries).
When I start compiling the project, it is compiled without any errors. However when writing the code, Eclipse reports errors on some functions of OpenCV, as if it did not know these functions. Since I have listed all the required headers and libraries in the makefile (see below), why does this problem occur?
CXXFLAGS = -O3 -g -Wall -fmessage-length=0 -I./include -I/usr/local/include/opencv
LIBS = -L/usr/local/lib -lcv -lcvaux -lhighgui -lcxcore -limgproc
MAIN_PROG_OBJS = MainProgram.o src/Utilities.o src/ImageStream.o src/VideoStream.o
MAIN_PROG_TARGET = MainProgram
TEST_PROG_OBJS = TestProgram.o src/Utilities.o
TEST_PROG_TARGET = TestProgram
$(MAIN_PROG_TARGET): $(MAIN_PROG_OBJS)
$(CXX) -o $(MAIN_PROG_TARGET) $(MAIN_PROG_OBJS) $(LIBS)
$(TEST_PROG_TARGET): $(TEST_PROG_OBJS)
$(CXX) -o $(TEST_PROG_TARGET) $(TEST_PROG_OBJS) $(LIBS)
all: $(MAIN_PROG_TARGET) $(TEST_PROG_TARGET)
clean:
rm -f $(MAIN_PROG_OBJS) $(MAIN_PROG_TARGET) $(TEST_PROG_OBJS) $(TEST_PROG_TARGET)
Eclipse tries to find the errors quickly, but does not update all the time. Do not rely only on the error messages of Eclipse.
For example if you have just added a file to your project, Eclipse might still be telling you that it could not find the file while in fact it is there.
Use Project -> Clean to update the error checking of Eclipse.