Cant build simple QT5 project - qt

I setup QT for windows using this tutorial - https://wiki.qt.io/MinGW-64-bit
I need to use CMAKE
I create empty project in qtcreator, but when i try cmake it i get this errors:
Starting to parse CMake project, using: "-DCMAKE_BUILD_TYPE:STRING=Debug", "-DCMAKE_CXX_COMPILER:STRING=C:/msys64/mingw64/bin/g++.exe", "-DCMAKE_CXX_COMPILER_TARGET :STRING=x86_64-pc-msys", "-DCMAKE_C_COMPILER:STRING=C:/msys64/mingw64/bin/gcc.exe", "-DCMAKE_C_COMPILER_TARGET:STRING=x86_64-pc-msys", "-DCMAKE_PREFIX_PATH:STRING=C:/msys64/mingw64", "-DCMAKE_SYSROOT:STRING=C:/msys64", "-DQT_QMAKE_EXECUTABLE:STRING=C:/msys64/mingw64/bin/qmake.exe".
The CXX compiler identification is GNU 9.2.0
Check for working CXX compiler: C:/msys64/mingw64/bin/g++.exe
Check for working CXX compiler: C:/msys64/mingw64/bin/g++.exe -- broken
CMake Error at C:/msys64/mingw64/share/cmake-3.15/Modules/CMakeTestCXXCompiler.cmake:53 (message):
The C++ compiler
"C:/msys64/mingw64/bin/g++.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: C:/Users/xxx/AppData/Local/Temp/QtCreator-RwlXKb/qtc-cmake-tQFVtoZK/CMakeFiles/CMakeTmp
Run Build Command(s):C:/msys64/usr/bin/ninja.exe cmTC_373cd && [1/2] Building CXX object CMakeFiles/cmTC_373cd.dir/testCXXCompiler.cxx.obj
FAILED: CMakeFiles/cmTC_373cd.dir/testCXXCompiler.cxx.obj
C:\msys64\mingw64\bin\g++.exe --sysroot=C:/msys64 -o CMakeFiles/cmTC_373cd.dir/testCXXCompiler.cxx.obj -c testCXXCompiler.cxx
/bin/sh: C:msys64mingw64bing++.exe: command not found
ninja: build stopped: subcommand failed.
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
Configuring incomplete, errors occurred!
See also "C:/Users/xxx/AppData/Local/Temp/QtCreator-RwlXKb/qtc-cmake-tQFVtoZK/CMakeFiles/CMakeOutput.log".
See also "C:/Users/xxx/AppData/Local/Temp/QtCreator-RwlXKb/qtc-cmake-tQFVtoZK/CMakeFiles/CMakeError.log".
CMake Deprecation Warning:
The 'cmake-server(7)' is deprecated. Please port clients to use the
'cmake-file-api(7)' instead.
CMake Project parsing failed.
It seems error in this string:
C:msys64mingw64bing++.exe
It because slashes not handled correctly.
So how i fix it? Where there setings stored?
UPDATE 1
Here is my CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
project(t2 LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt5 COMPONENTS Core Quick REQUIRED)
if(ANDROID)
add_library(t2 SHARED main.cpp qml.qrc)
else()
add_executable(t2 main.cpp qml.qrc)
endif()
target_compile_definitions(t2
PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>)
target_link_libraries(t2
PRIVATE Qt5::Core Qt5::Quick)
# QtCreator supports the following variables for Android, which are identical to qmake Android variables.
# Check http://doc.qt.io/qt-5/deployment-android.html for more information.
# These variables must use CACHE, otherwise QtCreator won't see them.
#if(ANDROID)
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android" CACHE INTERNAL "")
# if (ANDROID_ABI STREQUAL "armeabi-v7a")
# set(ANDROID_EXTRA_LIBS ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so CACHE INTERNAL "")
# endif()
#endif()
I try and launch cmake CMakeLists.txt and it crete makefile
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.15
# Default target executed when no arguments are given to make.
default_target: all
.PHONY : default_target
# Allow only one "make -f Makefile2" at a time, but pass parallelism.
.NOTPARALLEL:
#=============================================================================
# Special targets provided by cmake.
# Disable implicit rules so canonical targets will work.
.SUFFIXES:
# Remove some rules from gmake that .SUFFIXES does not remove.
SUFFIXES =
.SUFFIXES: .hpux_make_needs_suffix_list
# Suppress display of executed commands.
$(VERBOSE).SILENT:
# A target that is always out of date.
cmake_force:
.PHONY : cmake_force
#=============================================================================
# Set environment variables for the build.
# The shell in which to execute make rules.
SHELL = /bin/sh
# The CMake executable.
CMAKE_COMMAND = /usr/bin/cmake.exe
# The command to remove a file.
RM = /usr/bin/cmake.exe -E remove -f
# Escaping for special characters.
EQUALS = =
# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /c/projects/t2
# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /c/projects/t2
#=============================================================================
# Targets provided globally by CMake.
# Special rule for the target rebuild_cache
rebuild_cache:
#$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
/usr/bin/cmake.exe -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache
# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache
.PHONY : rebuild_cache/fast
# Special rule for the target edit_cache
edit_cache:
#$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
/usr/bin/ccmake.exe -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : edit_cache
# Special rule for the target edit_cache
edit_cache/fast: edit_cache
.PHONY : edit_cache/fast
# The main all target
all: cmake_check_build_system
$(CMAKE_COMMAND) -E cmake_progress_start /c/projects/t2/CMakeFiles /c/projects/t2/CMakeFiles/progress.marks
$(MAKE) -f CMakeFiles/Makefile2 all
$(CMAKE_COMMAND) -E cmake_progress_start /c/projects/t2/CMakeFiles 0
.PHONY : all
# The main clean target
clean:
$(MAKE) -f CMakeFiles/Makefile2 clean
.PHONY : clean
# The main clean target
clean/fast: clean
.PHONY : clean/fast
# Prepare targets for installation.
preinstall: all
$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall
# Prepare targets for installation.
preinstall/fast:
$(MAKE) -f CMakeFiles/Makefile2 preinstall
.PHONY : preinstall/fast
# clear depends
depend:
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend
#=============================================================================
# Target rules for targets named t2
# Build rule for target.
t2: cmake_check_build_system
$(MAKE) -f CMakeFiles/Makefile2 t2
.PHONY : t2
# fast build rule for target.
t2/fast:
$(MAKE) -f CMakeFiles/t2.dir/build.make CMakeFiles/t2.dir/build
.PHONY : t2/fast
#=============================================================================
# Target rules for targets named t2_autogen
# Build rule for target.
t2_autogen: cmake_check_build_system
$(MAKE) -f CMakeFiles/Makefile2 t2_autogen
.PHONY : t2_autogen
# fast build rule for target.
t2_autogen/fast:
$(MAKE) -f CMakeFiles/t2_autogen.dir/build.make CMakeFiles/t2_autogen.dir/build
.PHONY : t2_autogen/fast
main.o: main.cpp.o
.PHONY : main.o
# target to build an object file
main.cpp.o:
$(MAKE) -f CMakeFiles/t2.dir/build.make CMakeFiles/t2.dir/main.cpp.o
.PHONY : main.cpp.o
main.i: main.cpp.i
.PHONY : main.i
# target to preprocess a source file
main.cpp.i:
$(MAKE) -f CMakeFiles/t2.dir/build.make CMakeFiles/t2.dir/main.cpp.i
.PHONY : main.cpp.i
main.s: main.cpp.s
.PHONY : main.s
# target to generate assembly for a file
main.cpp.s:
$(MAKE) -f CMakeFiles/t2.dir/build.make CMakeFiles/t2.dir/main.cpp.s
.PHONY : main.cpp.s
t2_autogen/EWIEGA46WW/qrc_qml.o: t2_autogen/EWIEGA46WW/qrc_qml.cpp.o
.PHONY : t2_autogen/EWIEGA46WW/qrc_qml.o
# target to build an object file
t2_autogen/EWIEGA46WW/qrc_qml.cpp.o:
$(MAKE) -f CMakeFiles/t2.dir/build.make CMakeFiles/t2.dir/t2_autogen/EWIEGA46WW/qrc_qml.cpp.o
.PHONY : t2_autogen/EWIEGA46WW/qrc_qml.cpp.o
t2_autogen/EWIEGA46WW/qrc_qml.i: t2_autogen/EWIEGA46WW/qrc_qml.cpp.i
.PHONY : t2_autogen/EWIEGA46WW/qrc_qml.i
# target to preprocess a source file
t2_autogen/EWIEGA46WW/qrc_qml.cpp.i:
$(MAKE) -f CMakeFiles/t2.dir/build.make CMakeFiles/t2.dir/t2_autogen/EWIEGA46WW/qrc_qml.cpp.i
.PHONY : t2_autogen/EWIEGA46WW/qrc_qml.cpp.i
t2_autogen/EWIEGA46WW/qrc_qml.s: t2_autogen/EWIEGA46WW/qrc_qml.cpp.s
.PHONY : t2_autogen/EWIEGA46WW/qrc_qml.s
# target to generate assembly for a file
t2_autogen/EWIEGA46WW/qrc_qml.cpp.s:
$(MAKE) -f CMakeFiles/t2.dir/build.make CMakeFiles/t2.dir/t2_autogen/EWIEGA46WW/qrc_qml.cpp.s
.PHONY : t2_autogen/EWIEGA46WW/qrc_qml.cpp.s
t2_autogen/mocs_compilation.o: t2_autogen/mocs_compilation.cpp.o
.PHONY : t2_autogen/mocs_compilation.o
# target to build an object file
t2_autogen/mocs_compilation.cpp.o:
$(MAKE) -f CMakeFiles/t2.dir/build.make CMakeFiles/t2.dir/t2_autogen/mocs_compilation.cpp.o
.PHONY : t2_autogen/mocs_compilation.cpp.o
t2_autogen/mocs_compilation.i: t2_autogen/mocs_compilation.cpp.i
.PHONY : t2_autogen/mocs_compilation.i
# target to preprocess a source file
t2_autogen/mocs_compilation.cpp.i:
$(MAKE) -f CMakeFiles/t2.dir/build.make CMakeFiles/t2.dir/t2_autogen/mocs_compilation.cpp.i
.PHONY : t2_autogen/mocs_compilation.cpp.i
t2_autogen/mocs_compilation.s: t2_autogen/mocs_compilation.cpp.s
.PHONY : t2_autogen/mocs_compilation.s
# target to generate assembly for a file
t2_autogen/mocs_compilation.cpp.s:
$(MAKE) -f CMakeFiles/t2.dir/build.make CMakeFiles/t2.dir/t2_autogen/mocs_compilation.cpp.s
.PHONY : t2_autogen/mocs_compilation.cpp.s
# Help Target
help:
#echo "The following are some of the valid targets for this Makefile:"
#echo "... all (the default if no target is provided)"
#echo "... clean"
#echo "... depend"
#echo "... rebuild_cache"
#echo "... t2"
#echo "... edit_cache"
#echo "... t2_autogen"
#echo "... main.o"
#echo "... main.i"
#echo "... main.s"
#echo "... t2_autogen/EWIEGA46WW/qrc_qml.o"
#echo "... t2_autogen/EWIEGA46WW/qrc_qml.i"
#echo "... t2_autogen/EWIEGA46WW/qrc_qml.s"
#echo "... t2_autogen/mocs_compilation.o"
#echo "... t2_autogen/mocs_compilation.i"
#echo "... t2_autogen/mocs_compilation.s"
.PHONY : help
#=============================================================================
# Special targets to cleanup operation of make.
# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system
when i try to build it with makei get
C:\projects\t2>make
[ 16%] Automatic MOC and UIC for target t2
[ 16%] Built target t2_autogen
[ 33%] Automatic RCC for qml.qrc
Scanning dependencies of target t2
[ 50%] Building CXX object CMakeFiles/t2.dir/t2_autogen/mocs_compilation.cpp.o
[ 66%] Building CXX object CMakeFiles/t2.dir/main.cpp.o
[ 83%] Building CXX object CMakeFiles/t2.dir/t2_autogen/EWIEGA46WW/qrc_qml.cpp.o
[100%] Linking CXX executable t2.exe
CMakeFiles/t2.dir/main.cpp.o:main.cpp:
(.text$_ZN15QTypedArrayDataItE10deallocateEP10QArrayData[_ZN15QTypedArrayDataItE10deallocateEP10QArrayData]+0x1c): undefined reference to `QArrayData::deallocate(QArrayData*, unsigned long, unsigned long)'
CMakeFiles/t2.dir/main.cpp.o:main.cpp:(.text$_ZN15QTypedArrayDataItE10deallocateEP10QArrayData[_ZN15QTypedArrayDataItE10deallocateEP10QArrayData]+0x1c): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `QArrayData::deallocate(QArrayData*, unsigned long, unsigned long)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/t2.dir/build.make:126: t2.exe] Error 1
make[1]: *** [CMakeFiles/Makefile2:77: CMakeFiles/t2.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
Here source code of program:
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
return app.exec();
}

Ok, i fix it, it seems that Ninja tool cause all problems under windows!
I remove all files from my simple project, so it contains only this files:
CMakeLists.txt
Makefile
main.cpp
main.qml
qml.qrc
In Qtcreator i go to Tools - > Options -> Kits
CMake generator -> MSYS Makefile
In Cmake tool select with path C:\msys64\mingw64\bin\cmake.exe or you maybe need to add it manually
After i press Ok and exit from options all works just fine. CMAKE configure project and compile it and it runs.

Related

QT6 compilation error in new CLion project

I try to use CLion to make QT project, I have QT6 install and I just want to run a basic "helloworld" (to be sure that my configuration is ok). But i got some issues, my CLion problems terminal is empty but when I try to run the code I got this error :
"D:\CLion 2021.1.1\bin\cmake\win\bin\cmake.exe" --build D:\Qt\6.0.2\mingw81_64\bin --target GameRegister -- -j 12
Scanning dependencies of target GameRegister_autogen
[ 20%] Automatic MOC and UIC for target GameRegister
[ 20%] Built target GameRegister_autogen
Scanning dependencies of target GameRegister
[ 40%] Building CXX object CMakeFiles/GameRegister.dir/GameRegister_autogen/mocs_compilation.cpp.obj
[ 60%] Building CXX object CMakeFiles/GameRegister.dir/main.cpp.obj
[ 80%] Building CXX object CMakeFiles/GameRegister.dir/gameregister.cpp.obj
[100%] Linking CXX executable GameRegister.exe
Error copying file "D:/Qt/6.0.2/mingw81_64/lib/cmake/../../bin/Qt6Cored.dll" to "D:/Qt/6.0.2/mingw81_64/bin".
mingw32-make.exe[3]: *** [CMakeFiles\GameRegister.dir\build.make:141: GameRegister.exe] Error 1
mingw32-make.exe[3]: *** Deleting file 'GameRegister.exe'
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:95: CMakeFiles/GameRegister.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:102: CMakeFiles/GameRegister.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:136: GameRegister] Error 2
To make my configuration I followed this guide
https://www.jetbrains.com/help/clion/qt-tutorial.html#issues-limits
and I also look in Qt documentation to make my CMakeLists.txt.
my CMakeLists.txt :
cmake_minimum_required(VERSION 3.19)
project(GameRegister)
#Cmake with 20cpp version
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
#QT version
set(QT_VERSION 6)
set(REQUIRED_LIBS Core)
set(REQUIRED_LIBS_QUALIFIED Qt6::Core)
add_executable(${PROJECT_NAME}
main.cpp gameregister.cpp
gameregister.h
gameregister.ui
)
#Path to cmake lib in QT
set(CMAKE_PREFIX_PATH "D:/Qt/6.0.2/mingw81_64/lib/cmake")
if (NOT CMAKE_PREFIX_PATH)
message(WARNING "CMAKE_PREFIX_PATH is not defined, you may need to set it "
"(-DCMAKE_PREFIX_PATH=\"path/to/Qt/lib/cmake\" or -DCMAKE_PREFIX_PATH=/usr/include/{host}/qt{version}/ on Ubuntu)")
endif ()
#Find necessary packages
find_package(Qt${QT_VERSION} COMPONENTS ${REQUIRED_LIBS} REQUIRED)
find_package(Qt${QT_VERSION} COMPONENTS Widgets REQUIRED)
#Target packages
target_link_libraries(${PROJECT_NAME} ${REQUIRED_LIBS_QUALIFIED})
target_link_libraries(${PROJECT_NAME} Qt6::Widgets)
#auto generated by CLion on creation
if (WIN32)
set(DEBUG_SUFFIX)
if (CMAKE_BUILD_TYPE MATCHES "Debug")
set(DEBUG_SUFFIX "d")
endif ()
set(QT_INSTALL_PATH "${CMAKE_PREFIX_PATH}")
if (NOT EXISTS "${QT_INSTALL_PATH}/bin")
set(QT_INSTALL_PATH "${QT_INSTALL_PATH}/..")
if (NOT EXISTS "${QT_INSTALL_PATH}/bin")
set(QT_INSTALL_PATH "${QT_INSTALL_PATH}/..")
endif ()
endif ()
if (EXISTS "${QT_INSTALL_PATH}/plugins/platforms/qwindows${DEBUG_SUFFIX}.dll")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/platforms/")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${QT_INSTALL_PATH}/plugins/platforms/qwindows${DEBUG_SUFFIX}.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/platforms/")
endif ()
foreach (QT_LIB ${REQUIRED_LIBS})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${QT_INSTALL_PATH}/bin/Qt${QT_VERSION}${QT_LIB}${DEBUG_SUFFIX}.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>")
endforeach (QT_LIB)
endif ()
and that's my Run/Debug config :
So I don't know why i got this error, maybe one of my path is incorrect or I need to edit the configuration of my run/debug ?

How to compile sqlite3 extension - CSV virtual table

I am trying to use the CSV Virtual Table extension for sqlite3. I get stuck on the first step of compiling the extension on a Mac (MacOS High Sierra 10.13.6).
I downloaded the source code for csv.c from this page. I also grabbed the sqlite source code amalgamation from here.
I used the following command to compile:
gcc -g -fPIC -dynamiclib csv.c -o csv.dylib
However, I get the following error:
csv.c:115:3: error: no member named '__builtin___vsnprintf_chk' in 'struct sqlite3_api_routines'
sqlite3_vsnprintf(CSV_MXERR, p->zErr, zFormat, ap);
^~~~~~~~~~~~~~~~~
/usr/include/sqlite3ext.h:437:53: note: expanded from macro 'sqlite3_vsnprintf'
#define sqlite3_vsnprintf sqlite3_api->vsnprintf
~~~~~~~~~~~ ^
/usr/include/secure/_stdio.h:75:3: note: expanded from macro 'vsnprintf'
__builtin___vsnprintf_chk (str, len, 0, __darwin_obsz(str), format, ap)
^
csv.c:115:21: warning: incompatible integer to pointer conversion passing 'int' to parameter of type 'const void *' [-Wint-conversion]
sqlite3_vsnprintf(CSV_MXERR, p->zErr, zFormat, ap);
^~~~~~~~~
csv.c:67:19: note: expanded from macro 'CSV_MXERR'
#define CSV_MXERR 200
^~~
/usr/include/secure/_stdio.h:75:57: note: expanded from macro 'vsnprintf'
__builtin___vsnprintf_chk (str, len, 0, __darwin_obsz(str), format, ap)
^~~
/usr/include/secure/_common.h:39:54: note: expanded from macro '__darwin_obsz'
#define __darwin_obsz(object) __builtin_object_size (object, _USE_FORTIFY_LEVEL > 1 ? 1 : 0)
^~~~~~
csv.c:568:5: error: use of undeclared identifier 'sqlite3_str'
sqlite3_str *pStr = sqlite3_str_new(0);
^
csv.c:568:18: error: use of undeclared identifier 'pStr'
sqlite3_str *pStr = sqlite3_str_new(0);
^
csv.c:568:25: warning: implicit declaration of function 'sqlite3_str_new' is invalid in C99 [-Wimplicit-function-declaration]
sqlite3_str *pStr = sqlite3_str_new(0);
^
csv.c:571:5: warning: implicit declaration of function 'sqlite3_str_appendf' is invalid in C99 [-Wimplicit-function-declaration]
sqlite3_str_appendf(pStr, "CREATE TABLE x(");
^
csv.c:571:25: error: use of undeclared identifier 'pStr'
sqlite3_str_appendf(pStr, "CREATE TABLE x(");
^
csv.c:581:29: error: use of undeclared identifier 'pStr'
sqlite3_str_appendf(pStr, "%sc%d TEXT", zSep, iCol);
^
csv.c:588:31: error: use of undeclared identifier 'pStr'
sqlite3_str_appendf(pStr,"%s\"%w\" TEXT", zSep, z);
^
csv.c:597:31: error: use of undeclared identifier 'pStr'
sqlite3_str_appendf(pStr,"%sc%d TEXT", zSep, ++iCol);
^
csv.c:603:25: error: use of undeclared identifier 'pStr'
sqlite3_str_appendf(pStr, ")");
^
csv.c:604:18: warning: implicit declaration of function 'sqlite3_str_finish' is invalid in C99 [-Wimplicit-function-declaration]
CSV_SCHEMA = sqlite3_str_finish(pStr);
^
csv.c:604:37: error: use of undeclared identifier 'pStr'
CSV_SCHEMA = sqlite3_str_finish(pStr);
^
csv.c:643:27: error: use of undeclared identifier 'SQLITE_VTAB_DIRECTONLY'
sqlite3_vtab_config(db, SQLITE_VTAB_DIRECTONLY);
^
4 warnings and 10 errors generated.
What am I doing wrong?
Richard Hipp at sqlite.org posted a solution on how to compile an SQLite extension.
The script for compiling the CSV extension looks like this (based on https://www.sqlite.org/loadext.html and https://github.com/sqlite/sqlite/blob/master/README.md):
wget https://www.sqlite.org/src/tarball/sqlite.tar.gz
tar xzf sqlite.tar.gz
mkdir bld
cd bld
../sqlite/configure
make
gcc -g -I. -fPIC -dynamiclib ../sqlite/ext/misc/csv.c -o csv.dylib
Testing the script:
echo -e 'col_text,col_int\napples,3\noranges,5' > sample.csv
./sqlite3 '' '.load csv' 'CREATE VIRTUAL TABLE temp.t1 USING csv(filename="sample.csv");' 'SELECT * FROM t1;'
That's it.
You can also try compiling csv.c with an existing sqlite3 installation. For sqlite3 installed with Homebrew, it would be:
curl -O https://raw.githubusercontent.com/sqlite/sqlite/master/ext/misc/csv.c
gcc -g -I/usr/local/opt/sqlite/include -fPIC -dynamiclib csv.c -o csv.dylib
/usr/local/opt/sqlite/bin/sqlite3 '' '.load csv'
The last line is testing the newly compiled library in the Homebrew sqlite3. The default $ sqlite3 comes from the MacOS bundle and is outdated sometimes.
I managed to find a workaround and use an Ubuntu docker container, where I was able to successfully compile and use the extension. Here are the steps I followed:
docker run -ti --rm -v $(pwd):/host ubuntu bash
# Steps to build SQLite and CSV Virtual Table extension from source inside an Ubuntu docker container
cd /host
apt update
apt install -y vim build-essential zip wget
wget https://sqlite.org/2020/sqlite-autoconf-3310100.tar.gz
tar xvf sqlite-autoconf-3310100.tar.gz
cd sqlite-autoconf-3310100
./configure
make
./sqlite3
# Obtain csv.c and change <sqlite3ext.h> to "sqlite3ext.h" in the file
vi csv.c
gcc -g -fPIC -shared csv.c -o csv.so
./sqlite3
#sqlite> .load ./csv
#sqlite> CREATE VIRTUAL TABLE temp.t1 USING csv(filename='/host/users.csv',header);
#sqlite> .headers on
#sqlite> SELECT * FROM t1 LIMIT 1;
You can use a similar process to build for a Lambda function (CentOS). See this github repo for more details.
I still haven't figured out how to get it to compile directly on Mac, so any help would be greatly appreciated!
Leveraging off of Anton's answer for an Ubuntu-like distro, the following is mostly workable:
wget https://www.sqlite.org/src/tarball/sqlite.tar.gz
tar xzf sqlite.tar.gz
mkdir bld
cd bld
../sqlite/configure
make
A gotchas in getting this far:
You may need to do this:
sudo apt-get install tcl8.6-dev
It will complain about not having access to tcl. If that's the case, you need to install and go back to the configure step.
Now, make should work unless you have other missing dependencies.
Assuming that works, now for the gcc:
gcc -I. -fPIC -shared ../sqlite/ext/misc/csv.c -o csv.so -lm
Now it's time to run. You need to set LD_LIBRARY_PATH. Assuming you are still in the bld directory:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`
or substitute the `pwd` for your full path to the csv.so file.
NOW! Now, you can run it. Enjoy.

GNU-make : generates "Circular ....... dependency dropped" messages

(Please excuse my English)
I'm using GNU-make for compiling typescript codes. GNU-make is more simple and convenient than other similar tools. My original Makefile is below, and it works well.
all: test.js request.js server.js
test.js: test.ts
compiler test.ts
request.js: request.ts
compiler request.ts
server.js: server.ts
compiler server.ts
clean :
del test.js request.js server.js
As files to compile are increased, I modified the Makefile like below.
TARGETS=test.js request.js server.js
all: $(TARGETS)
.SECONDEXPANSION:
%: $$(basename $$#).ts
compiler $(basename $#).ts
clean :
del $(TARGETS)
The modified Makefile also works well, but generates these messages.
make: Circular test.ts <- test.ts dependency dropped.
make: Circular request.ts <- request.ts dependency dropped.
make: Circular server.ts <- server.ts dependency dropped.
make: Nothing to be done for 'all'.
How can I remove the "Circular ....... dependency dropped" messages?
Why are you using secondary expansion? This seems like a trivial usage of standard pattern rules, no need for complicated features:
%.js: %.ts
compiler $<

:: error: collect2: ld returned 1 exit status with QT and opengl

I'm trying to use a QGLWidget in a QT application, and I've added the "QT += opengl" line into the .pro file but I am now getting :: error: collect2: ld returned 1 exit status when I attempt to compile my program
the compile output shows the following,
Running build steps for project MapEditor...
Configuration unchanged, skipping qmake step.
Starting: "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" -w
mingw32-make: Entering directory `C:/Qt/2010.05/MapEditor-build-desktop'
C:/Qt/2010.05/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Qt/2010.05/MapEditor-build-desktop'
g++ -enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -mthreads -Wl -Wl,-subsystem,windows -o debug\MapEditor.exe debug/Main.o debug/window.o debug/glwidget.o debug/moc_window.o debug/moc_glwidget.o -L"c:\Qt\2010.05\qt\lib" -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmaind -lQtOpenGLd4 -lQtGuid4 -lQtCored4
mingw32-make[1]: Leaving directory `C:/Qt/2010.05/MapEditor-build-desktop'
mingw32-make: Leaving directory `C:/Qt/2010.05/MapEditor-build-desktop'
debug/moc_glwidget.o:moc_glwidget.cpp:(.rdata$_ZTV8GLWidget[vtable for GLWidget]+0x14): undefined reference to `GLWidget::~GLWidget()'
debug/moc_glwidget.o:moc_glwidget.cpp:(.rdata$_ZTV8GLWidget[vtable for GLWidget]+0x18): undefined reference to `GLWidget::~GLWidget()'
debug/moc_glwidget.o:moc_glwidget.cpp:(.rdata$_ZTV8GLWidget[vtable for GLWidget]+0x118): undefined reference to `non-virtual thunk to GLWidget::~GLWidget()'
debug/moc_glwidget.o:moc_glwidget.cpp:(.rdata$_ZTV8GLWidget[vtable for GLWidget]+0x11c): undefined reference to `non-virtual thunk to GLWidget::~GLWidget()'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [debug\MapEditor.exe] Error 1
mingw32-make: *** [debug] Error 2
The process "C:/Qt/2010.05/mingw/bin/mingw32-make.exe" exited with code %2.
Error while building project MapEditor (target: Desktop)
When executing build step 'Make'
and my .pro file contains the following,
TARGET = MapEditor
TEMPLATE =app
QT += opengl
SOURCES += \
Main.cpp \
window.cpp \
glwidget.cpp
HEADERS += \
window.h \
glwidget.h
Check you .pro file (i.e. project file) that u have added all the class files and header files in SOURCES and HEADERS tags.[For this purpose run qmake command from build menubar options]
Also check that u have declared the Q_OBJECT macro in the starting of your glwidget class.
It looks like some file is missing. Did you add this to your header?
#include <QtOpenGL>

Can't build a qt project using qtservice

I'm trying to use QtService from QtSolution in a Qt project.
I've unzipped it and run:
configure.bat -library
qmake
mingw32-make
the debug and release dll were placed inside C:\Qt\2010.03\qt\bin\
Examples were correctly built .
I added this line at the bottom of my .pro file:
include(../QtSolutions/qtservice/src/qtservice.pri)
and I was able to browse the qtservice's sources from the project source tree.
When I try to build my project I get:
Running build steps for project EMCSolutionCrawler...
Configuration unchanged, skipping QMake step.
Starting: C:/Qt/2010.03/mingw/bin/mingw32-make.exe -w
mingw32-make: Entering directory `C:/Progetti/EMCSolutionCrawler'
c:\qt\2010.03\qt\bin\qmake.exe -spec ..\..\Qt\2010.03\qt\mkspecs\win32-g++ -win32 -o Makefile EMCSolutionCrawler.pro
mingw32-make: Leaving directory `C:/Progetti/EMCSolutionCrawler'
mingw32-make: Entering directory `C:/Progetti/EMCSolutionCrawler'
C:/Qt/2010.03/mingw/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory `C:/Progetti/EMCSolutionCrawler'
g++ -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_QTSERVICE_IMPORT -DQT_DLL -DQT_SQL_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT ../QtSolutions/qtservice/src/QtService.cpp -o ../QtSolutions/qtservice/src/QtService
mingw32-make[1]: Leaving directory `C:/Progetti/EMCSolutionCrawler'
mingw32-make: Leaving directory `C:/Progetti/EMCSolutionCrawler'
In file included from ../QtSolutions/qtservice/src/QtService.cpp:47:
../QtSolutions/qtservice/src/qtservice.h:50:35: error: QtCore/QCoreApplication: No such file or directory
In file included from ../QtSolutions/qtservice/src/QtService.cpp:48:
../QtSolutions/qtservice/src/qtservice_p.h:50:30: error: QtCore/QStringList: No such file or directory
../QtSolutions/qtservice/src/QtService.cpp:51:25: error: QtCore/QTimer: No such file or directory
../QtSolutions/qtservice/src/QtService.cpp:52:26: error: QtCore/QVector: No such file or directory
../QtSolutions/qtservice/src/QtService.cpp:53:27: error: QtCore/QProcess: No such file or directory
../QtSolutions/qtservice/src/QtService.cpp:426:25: error: qtservice.moc: No such file or directory
In file included from ../QtSolutions/qtservice/src/QtService.cpp:47:
../QtSolutions/qtservice/src/qtservice.h:73: error: ISO C++ forbids declaration of 'Q_DECLARE_PRIVATE' with no type
../QtSolutions/qtservice/src/qtservice.h:74: error: expected ';' before 'public'
../QtSolutions/qtservice/src/qtservice.h:80: error: ISO C++ forbids declaration of 'QString' with no type
../QtSolutions/qtservice/src/qtservice.h:80: error: expected ',' or '...' before '&' token
../QtSolutions/qtservice/src/qtservice.h:86: error: 'QString' does not name a type
../QtSolutions/qtservice/src/qtservice.h:87: error: 'QString' does not name a type
../QtSolutions/qtservice/src/qtservice.h:88: error: 'StartupType' does not name a type
../QtSolutions/qtservice/src/qtservice.h:89: error: 'QString' does not name a type
../QtSolutions/qtservice/src/qtservice.h:91: error: ISO C++ forbids declaration of 'QString' with no type
../QtSolutions/qtservice/src/qtservice.h:91: error: expected ',' or '...' before '&' token
../QtSolutions/qtservice/src/qtservice.h:110: error: ISO C++ forbids declaration of 'Q_DECLARE_PRIVATE' with no type
../QtSolutions/qtservice/src/qtservice.h:111: error: expected ';' before 'public'
../QtSolutions/qtservice/src/qtservice.h:125: error: 'ServiceFlags' has not been declared
../QtSolutions/qtservice/src/qtservice.h:125: error: ISO C++ forbids declaration of 'Q_DECLARE_FLAGS' with no type
../QtSolutions/qtservice/src/qtservice.h:127: error: expected ';' before 'QtServiceBase'
../QtSolutions/qtservice/src/qtservice.h:130: error: 'QString' does not name a type
...
What am I missing?
Environment infomation:
Qt 4.6.3 (mingw - LGPL)
Windows XP SP3
QtService 2.6
Thank you for your time.
Just a guess: I don't see a include -IC:\Qt\2010.03\qt\include in your call of g++. So the compiler can't find the Qt Headers. I tink there is something wrong in your EMCSolutionCrawler.pro.

Resources