libxlsxwriter with MinGW - c++

For two days I have spent several hours trying to get libxlsxwriter to work with mingw on Windows. I followed the instructions to install and build the library, but every time I attempt to include the header files in one of my projects and use one of the function in the library, I end up getting the same error:
D:\Apps\CLion\bin\cmake\win\bin\cmake.exe --build C:\Users\Simon\CLionProjects\myexcel\cmake-build-debug --target all -- -j 4
[ 50%] Linking CXX executable myexcel.exe
D:/Apps/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: CMakeFiles\myexcel.dir/objects.a(main.cpp.obj): in function `main':
C:/Users/Simon/CLionProjects/myexcel/main.cpp:4: undefined reference to `workbook_new'
D:/Apps/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Simon/CLionProjects/myexcel/main.cpp:5: undefined reference to `workbook_add_worksheet'
D:/Apps/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Simon/CLionProjects/myexcel/main.cpp:8: undefined reference to `worksheet_write_string'
D:/Apps/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Simon/CLionProjects/myexcel/main.cpp:9: undefined reference to `workbook_close'
collect2.exe: error: ld returned 1 exit status
mingw32-make.exe[2]: *** [CMakeFiles\myexcel.dir\build.make:85: myexcel.exe] Error 1
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:75: CMakeFiles/myexcel.dir/all] Error 2
mingw32-make.exe: *** [Makefile:83: all] Error 2
My code is very basic (it's pretty much one of the sample codes provided):
#include "xlsxwriter.h"
int main() {
lxw_workbook *workbook = workbook_new("myexcel.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
int row = 0;
int col = 0;
worksheet_write_string(worksheet, row, col, "Hello me!", NULL);
return workbook_close(workbook);
}
I have tried several ways to get deploy mingw, but I've ultimately settled for msys2 as a platform to host mingw as I feel the *nix environments are beneficial when it comes to managing a multitude of packages and it comes with the needed zlib preinstalled.
For all it'S worth here's my toolchain configuration in CLion 2019.3
and here's my project configuration:
Any ideas what's wrong here? I am a newby as it relates to C/C++... help is very much appreciated!
EDIT:
I've tried to install the built files from the mys2 console with pacman pacman -Ss xlsx. From what it looks like, it's already installed. This is the output of the console:
$ pacman -Ss xlsx
mingw32/mingw-w64-i686-libxlsxwriter 0.9.4-1
A C library for creating Excel XLSX files (mingw-w64)
mingw32/mingw-w64-i686-python-openpyxl 3.0.2-1
A python library to read/write Excel 2007 xlsx/xlsm file (mingw-w64)
mingw32/mingw-w64-i686-python-xlsxwriter 1.2.7-1
A Python module for creating Excel XLSL files (mingw-w64)
mingw32/mingw-w64-i686-xlnt 1.4.0-1
User-friendly xlsx library for C++14 (mingw-w64)
mingw64/mingw-w64-x86_64-libxlsxwriter 0.9.4-1
A C library for creating Excel XLSX files (mingw-w64)
mingw64/mingw-w64-x86_64-python-openpyxl 3.0.2-1
A python library to read/write Excel 2007 xlsx/xlsm file (mingw-w64)
mingw64/mingw-w64-x86_64-python-xlsxwriter 1.2.7-1
A Python module for creating Excel XLSL files (mingw-w64)
mingw64/mingw-w64-x86_64-xlnt 1.4.0-1
User-friendly xlsx library for C++14 (mingw-w64)
I don't get it, frankly. There is no libxlsxwriter.so anywhere. I have the two files (libxlsxwriter.a, libxlsxwriter.dll) in the usr/local folder and in the home folder (where they have been built originally).

You can find the libxlsxwriter library as Msys2 package and install them using (from MinGW 64 shell) the following command:
pacman -S mingw-w64-x86_64-libxlsxwriter

Related

VS Code building .exe files in Windows 10, how do I change to build for windows 10 compatibility

So I am having trouble building my .exe files in visual studio code for my current windows OS. for some reason, my .exe files, when I run a diagnostic on them, seem to only be compatible for windows 8, not 10.
Using
Processor architecture: AMDx64
system: x64 based PC
VS code version: 1.74.3
When creating a simple "Hello World" application I tried following this tutorial, and it didn't have any problems. It was when I followed the tutorial for importing external libraries that the problems ocured.
I’ve tried importing an external library, and used msys2 to install the files in the bin/include/lib folders for mingw64.
I set my include path to the include folder, and I’ve set my compiler to default. My JSON tasks document appears correct, and when I build the .exe file, it builds successfully… but it only builds an executable file compatible for windows eight
I ran the properties compatibility test, and this is the output I get
What exactly do I need to do in order to change the OS version to make it compatible to run on both the visual studio code terminal, and my system terminal as well?
the following is the output once I ran the build process
Starting build...
C:\msys64\mingw64\bin\cpp.exe -IC:\msys64\mingw64\include -fdiagnostics-color=always -g "D:\Documents\C++\VS_Code\FMT Import\FMTImport.cpp" -o "D:\Documents\C++\VS_Code\FMT Import\FMTImport.exe" -lfmt
>Build finished successfully.
edit:
config name:C:/msys64/mingw64/bin/g++.exe
compiler path: C:/msys64/mingw64/bin/g++.exe
intellisense mode: ${default}
edit 2:
running terminal attempts to build..
for g++
D:\Documents\C++\VS_Code\FMT Import>g++ -o FMTImport FMTImport.cpp
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\William\AppData\Local\Temp\ccshGhdE.o:FMTImport.cpp:(.text+0x8c): undefined reference to `fmt::v9::vprint(fmt::v9::basic_string_view<char>, fmt::v9::basic_format_args<fmt::v9::basic_format_context<fmt::v9::appender, char> >)'
collect2.exe: error: ld returned 1 exit status
for clang++
D:\Documents\C++\VS_Code\FMT Import>clang++ FMTImport.cpp -o FMTImport
FMTImport.cpp:1:10: fatal error: 'fmt/format.h' file not found
#include <fmt/format.h>

NPM sqlite3 with sqlcipher support

I am trying to cross compile NPM Sqlite3 with sqlcipher support. I am using Ubuntu 16.04 to cross compile for linux armv7 based SOC(system on chip).
So I started with cross-compiling OpenSSL to build sqlcipher for arm. I successfully cross compiled sqlcipher to produce a static library (libsqlcipher.a).
Now I am trying to get the NodeJS side of the project. I need sqlite with sqlcipher support, compiled for arm. I am using SOC SDK to built till now.
I am using node v4.6.1 and npm v2.15.9 to cross compile. I made sure I have the same version installed on Ubuntu as the SOC.
The command I use to cross compile is as follows :
npm install sqlite3 --target_arch=arm --enable-static=yes --build-from-source --sqlite_libname=sqlcipher -fPIC --sqlite=home/onkar/Library/sqlcipher-master/.libs --verbose
I exported the location of the libsqlcipher.a to LDFLAGS. I get the following error when I try to cross compile. Can someone help me with this error?
/home/linuximage/sdk/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/5.2.1/real-ld: error: /home/Library/sqlcipher-master/.libs/libsqlcipher.a(sqlite3.o): requires unsupported dynamic reloc R_ARM_THM_MOVW_ABS_NC; recompile with -fPIC
collect2: error: ld returned 1 exit status
node_sqlite3.target.mk:129: recipe for target 'Release/obj.target/node_sqlite3.node' failed
make: *** [Release/obj.target/node_sqlite3.node] Error 1
Please let me know if you require any additional information, I would be more than happy to provide you with the same.
Thanks,
Onkar
In the first instance, you should check if the -fPIC (position independent code) flag was correctly applied when the libsqlcipher.a file was originally created.
In your output above, it looks like the linker is using the file at:
/home/Library/sqlcipher-master/.libs/libsqlcipher.a
Run the command
objdump -r /home/Library/sqlcipher-master/.libs/libsqlcipher.a | more
... and check for a line close to the start of the output beginning with the text
RELOCATION RECORDS FOR
If you see this line, then the library doesn't contain position independent code.

MySQL program cannot find -lmysqld error

I'm compiling Cryptdb in my ubuntu 16.04, which uses -lmysqld option. My MySQL version is 5.5.52; The program reports the following error:
/usr/bin/ld: cannot find -lmysqld
collect2: error: ld returned 1 exit status
I have followed the instruction in Mysql Installation
to install mysql, including using make install to copy some .h file to /usr/local/mysql/...; So I wounder how to make -lmysqld work.
Also, the program uses such files as select_sql.h, which does not appear in /user/local/mysql/...; Currently, I have to find those files in the mysql source code directory: ./mysql-5.5.52/sql and add -I option in Makefile, can anyone find a more elegant way?
Thanks:)

Compile c++ code in R does not work anymore

I start saying that i am a newbie in programming and then i am not sure i will be able to explain well my problem.
I had some c++ code i wrote, this code are loaded and used by some R functions.
To compile the code i used the following:
R CMD SHLIB MyCode.cpp
and i loaded the library in R with
dyn.load("MyCOde.so")
Sometimes i built also an R package and i was able to load it into R.
If i do all these stuff on a Mac with mountain lion everything work fine, but now that i switched to mavericks, i have some problems. The R CMD SHLIB MyCode.cpp command works but when i used dyn.load("MyCOde.so") i get the following text:
Errore in dyn.load(paste(dir_function, "MyCOde.so", sep = "")) :
unable to load shared object 'MyCOde.so':
dlopen(MyCOde.so, 6): Symbol not found: __ZNSt8ios_base4InitC1Ev
Referenced from: MyCOde.so
Expected in: flat namespace
in MyCOde.so
Moreover if i try to load the package in R, i get the following
ld: warning: directory not found for option '-L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2'
ld: library not found for -lquadmath
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [MyCode.so] Error 1
Can someone helps me?
Based on the helpful website of:
thecoatlessprofessor
Type this into your terminal shell:
curl -O http://r.research.att.com/libs/gfortran-4.8.2-darwin13.tar.bz2
sudo tar fvxz gfortran-4.8.2-darwin13.tar.bz2 -C /
This will create what you need to resume compiling as before.
Since it starts to work I can publish the answer for such a cases.
When you change the compiler and standard libraries - please note that different libraries have different implementation and different standard support. Changing the basement of your system might require total rebuild of your system with the new C++ standard library.
Your libraries are not the exception. So if have the errors in your linker like this:
warning: directory not found for option
'-L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2'
apply next algorithm:
Check whether the directory /usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2 still exists. I bet it is not.
Check if you still have the libstdc++ from the missed compiler? Usually if you upgrade the same compiler and the C++ standard library ABI does not change everything should continue to work. If the ABI changed or you switch standard C++ library and compiler - you face the massive system rebuild.
Recompile your library and apps with the new C++ standard library and compiler.

Can't create QT postgresql plugin for Symbian device

I'm trying to create postgresql plugin for Symbian device but I can't compile it. I'm working on Windows 7 64bit.
I did everything according to this article: http://doc.qt.io/archives/qt-4.7/sql-driver.html#qpsql
C:\QtSDK\QtSources\4.8.1\src\plugins\sqldrivers\psql>qmake "INCLUDEPATH+=C:\Program Files (x86)\PostgreSQL\8.3\include" "LIBS+=C:\Program Files (x86)\PostgreSQL\8.3\lib\libpq.lib" psql.pro
WARNING: (internal):1: Unescaped backslashes are deprecated.
So, it looked OK. Then...
C:\...drivers\psql>C:\QtSDK\Symbian\tools\sbs\win32\mingw\bin\make debug-gcce
sbs -c arm.v5.udeb.gcce4_4_1
python.exe is not recognized as an internal or external command, operable program or batch file.
make: *** [debug-gcce] Error 9009
I noticed, that sbs_home was set to python directory but it was not in the path, then the make could not find the script raptor_start.py:
C:\...drivers\psql>echo %sbs_home%
C:\QtSDK\Symbian\tools\sbs\win32\python27
C:\...drivers\psql>set path=%path%;%sbs_home%
C:\...drivers\psql>C:\QtSDK\Symbian\tools\sbs\win32\mingw\bin\make debug-gcce
sbs -c arm.v5.udeb.gcce4_4_1
python.exe: can't open file C:\QtSDK\Symbian\tools\sbs\win32\python27\python\raptor_start.py': [Errno 2] No such file or directory
make: *** [debug-gcce] Error 2
C:\...drivers\psql>set sbs_home=C:\QtSDK\Symbian\tools\sbs
so, when I started compiling I got this error:
C:/QtSDK/Symbian/SDKs/Symbian3Qt474/epoc32/include/stdapis/stlportv5/stl/_istream.c:650: warning: suggest parentheses around '&&' within '||' target : epoc32\release\armv5\udeb\qsqlpsql.dll [arm.v5.udeb.gcce4_4_1]
FAILED linkandpostlink for arm.v5.udeb.gcce4_4_1: epoc32\release\armv5\udeb\qsqlpsql.dll
mmp: qsqlpsql_dll.mmp
c:/qtsdk/symbian/tools/gcce4/bin/../lib/gcc/arm-none-symbianelf/4.4.1/../../../../arm-none-symbianelf/bin/ld.exe: warning: C:/QtSDK/Symbian/SDKs/Symbian3Qt474/epoc32/release/armv5/udeb/usrt3_1.lib(ucppinit.o) uses variable-size enums yet the output is to use 32-bit enums; use of enum values across objects may fail
C:/QtSDK/Symbian/SDKs/Symbian3Qt474/epoc32/build/psql/c_8d95259b570e1766/qsqlpsql_dll/armv5/udeb/qsql_psql.o: In function `qMakeError': C:/QtSDK/QtSources/4.8.1/src/sql/drivers/psql/qsql_psql.cpp:175: undefined reference to `PQerrorMessage'
....many undefined references...
C:/QtSDK/QtSources/4.8.1/src/sql/drivers/psql/qsql_psql.cpp:117: undefined reference to `PQfreemem'
collect2: ld returned 1 exit status
mingw32-make[1]: *** [C:/QtSDK/Symbian/SDKs/Symbian3Qt474/epoc32/release/armv5/udeb/qsqlpsql.dll] Error 1
sbs: error: The make-engine exited with errors.
sbs : warnings: 3
sbs : errors: 2
built 'arm.v5.udeb.gcce4_4_1'
Run time 5 seconds
sbs: build log in C:\QtSDK\Symbian\SDKs\Symbian3Qt474\epoc32\build\Makefile.2012-06-26-15-03-12.78-2996.log
make: *** [debug-gcce] Error 1
Has anybody idea, what with it?
You are trying to build an Symbian/ARM application using precompiled binary postgresql client library for Windows. This won't ever work. The instructions you refer to only show how to build for OS X, Unix and Mac targets natively. You're cross compiling for Symbian.
You'd first need to obtain a binary version of the postgresql client library compiled for Symbian. It might exist out there, or you may need to compile it yourself. I don't think that the library supports Symbian as a target, and I couldn't readily find any Symbian ports for download. You may be out of luck for a trivial solution. A port might not be entirely out of the question, though -- perhaps the platform-specific code is localized enough.