I have a problem with my QTCreator-generated Makefile. Everything is working fine except when I try to create myself a new executable file for my tests, my terminal says: bash: ./RunTests: cannot execute binary file: Exec format error
Here is how my MakeFile rule looks like:
TESTS: ../WannaBeRPG/testes.cpp ../WannaBeRPG/hero.h ../WannaBeRPG/charinterface.h
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o RunTests ../WannaBeRPG/testes.cpp
Flags are:
CXX = g++
CXXFLAGS = -pipe -g -std=gnu++0x -Wall -W -fPIC $(DEFINES)
INCPATH = -I../WannaBeRPG -I. -I/usr/lib64/qt5/mkspecs/linux-g++
DEFINES = -DQT_QML_DEBUG
If that is anyhow helpful here is my testes.cpp file:
#include <gtest/gtest.h>
#include "hero.h"
TEST(teee, HPTEST)
{
Hero myHero("Hika",150,100,0,0,0,0,0,0,0);
EXPECT_EQ(100,myHero.getHP());
}
int main_tests(int argc, char* argv[])
{
testing::InitGoogleTest(&argc,argv);
return RUN_ALL_TESTS();
}
I am using Fedora. Any ideas why does this works this way? Primary exec from this Makefile works completely fine.
The -c
argument to g++
tells it not to link your binary. Thus, your output file is an object file rather than an executable.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.