我在Qt Creator 4.5.2。中加载了一个C ++项目。
我有一个仅标头的库,以及一个测试该库的测试项目。测试项目具有清晰的main
功能。
测试项目正确构建。当我从控制台运行生成的可执行文件时,它可以按预期运行,但是Qt Creator无法运行或调试测试项目,并出现以下错误:
/ usr / lib / x86_64-linux-gnu / Scrt1.o:-1:在函数'_start':]中>
(。text + 0x20):-1:错误:未定义对“ main”的引用:-1:错误:
collect2:错误:ld返回了1退出状态
我看过SO,发现的所有人都是忘记写主要功能的人,这不是我的情况。
这是怎么回事?我该如何解决?
我的主要功能很简单:
#include "test_math.h" #include "test_engine.h" /** * @brief main * @return */ int main() { std::cout << "GridCal++ tests" << std::endl; gce_test::sp_submatrix_test(); //gce_test::sp_mat_test(makeA, makeb); gce_test::sp_submatrix_test(); gce_test::graph_test(); gce_test::test_engine_1(); gce_test::test_engine_wei_min(); gce_test::test_lynn_5bus(); gce_test::state_stimation_test(); gce_test::test_psse_file(); gce_test::test_json(); std::cout << "\n\nAll tests done." << std::endl; std::cout << "Press ENTER to exit." << std::endl; std::string line; std::getline(std::cin, line); return 0; }
具有
.pro
的项目的main.cpp
是:
QT += core
QT -= gui
CONFIG += c++11
CONFIG -= qt
TARGET = GridCal_tests
CONFIG += console
CONFIG -= app_bundle
# remove possible other optimization flags
QMAKE_CXXFLAGS_RELEASE -= -O
QMAKE_CXXFLAGS_RELEASE -= -O1
QMAKE_CXXFLAGS_RELEASE -= -O2
# add the desired -O3 if not present
QMAKE_CXXFLAGS_RELEASE *= -O3
TEMPLATE = app
INCLUDEPATH += "$$PWD/../GridCal"
INCLUDEPATH += "$$PWD/../libs/armadillo/include"
unix {
# Intel MKL (Linux)
# Use https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor
# to configure the include directived for Intel MKL
# MKLROOT = /opt/intel/mkl
# INCLUDEPATH += $${MKLROOT}/include
# MKL linking options: Static | 32-bit integer interface layer | OpenMP threading
# QMAKE_CXXFLAGS += -m64
# LIBS += -Wl,--start-group $${MKLROOT}/lib/intel64/libmkl_intel_lp64.a $${MKLROOT}/lib/intel64/libmkl_intel_thread.a $${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -liomp5 -lpthread -lm -ldl
# MKL linking options: Static | 64-bit integer interface layer | OpenMP threading
# Seems not to be suited for the problem since it cannot solve spsolve...
# LIBS += -Wl,--start-group $${MKLROOT}/lib/intel64/libmkl_intel_ilp64.a $${MKLROOT}/lib/intel64/libmkl_intel_thread.a $${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group -liomp5 -lpthread -lm -ldl
# QMAKE_CXXFLAGS += -DMKL_ILP64 -m64
# OpenBlas (static linking for GCC Linux)
LIBS += "$$PWD/../libs/lib_linux64/openblas/lib/libopenblas.a"
LIBS += -lpthread -lgfortran
}
win32 {
# Intel MKL (Windows with MS C/C++ compiler)
# Use https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor
# to configure the include directived for Intel MKL
MKLROOT = /opt/intel/mkl
INCLUDEPATH += $${MKLROOT}/include
# MKL linking options: Static | 32-bit integer interface layer | OpenMP threading
#LIBS += mkl_intel_lp64.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib
# MKL linking options: Static | 64-bit integer interface layer | OpenMP threading
LIBS += mkl_intel_ilp64.lib mkl_intel_thread.lib mkl_core.lib libiomp5md.lib
QMAKE_CXXFLAGS += /DMKL_ILP64
}
HEADERS += \
test_engine.h \
test_math.h
SOURCES += \
main.cpp
message($$INCLUDEPATH)
message($$LIBS)
我已经将一个C ++项目加载到Qt Creator 4.5.2中。我有一个仅标头的库,以及一个测试该库的测试项目。测试项目具有明确的主要功能。测试项目建立了...
如果有人在钦奈或泰米尔纳德邦寻找基于位置的营销服务提供商,我会推荐SMSConnect。让我告诉他们,希望对您有帮助。