Problems building XLNT library for Visual Studio 2017 - c++

I am having trouble building the XLNT (https://github.com/tfussell/xlnt) library in Visual Studio 2017, and I'm confused. I downloaded the latest version of the library and the latest version of CMake. When I ran the CMake gui, it couldn't find the libstudxml files. A post said that those needed to be downloaded; so I downloaded that library (https://www.codesynthesis.com/projects/libstudxml/#download) and placed it in third-party/libstudxml.
Then I got errors that it couldn't find some .hxx files in libstudxml. I found this article, https://discourse.cmake.org/t/cmake3-20-cant-generate-xint-package/2987, that said I needed to replace libstudxml in some paths in the libstudxml.build\CMakeLists.txt file with just xml. Then it still couldn't find these three .hxx files (content.hxx, exception.hxx, and forward.hxx). I looked in the libstudxml/xml folder (they were all there but extensionless). I changed the CMakeLists.txt file to not have the .hxx extension and Cmake was able to generate.
When I went to compile it in Visual Studio (hitting Project in the Cmake GUI), I got errors that some files couldn't find the content.hxx file again and the builds failed. I'm kind of running in circles. To get cmake to generate, I had to remove the .hxx extensions, but then some files complain because they are looking for them. I tried leaving the three files witout the extensions and removing the extensions from the CMakeLists.txt file, but then some of the files were looking for the files without the extension. Leaving the files both with and without the extension was also a cluster. I understand that C++ can handle extensionless header files, but the CMake file seems to want extension, but I don't think VS is happy with them.
Additionally, while I needed to change the folder name to be xml instead of libstudxml for CMake, various include files in the source code are still looking for libstudxml; so that doesn't work.
Any thoughts?
Thanks--
Al

I experienced the same problems with the same progress and blockages. Indeed changing the extensions or locations did not solve the problem. Then I tried to find another version of the libstudxml library, the creator of xlnt might have used an other one.
So I found the following archive: https://pkg.cppget.org/1/beta/libstudxml/
and placed the files in \xlnt-master\third-party\libstudxml , without modifying the names of the CMake path. This time I was able to compile the library (mingw32-make, I'm not using VS17 in my case).

Related

How do I get xlnt library / cMake to work

I previously built a programme in C#, now I wanted to write it in C++ to learn this language a bit. I need access to an xlsx file and I want to use XLNT library. The problem is I have absolutely no idea how to get it to work. I read some other topics on SO but nothing makes sense to me at all. First of all, isn't there a simple way to use this library? Like, when I wanted to add a library in C# I just installed the NuGet package and that was all, it simply worked. Isn't it that simple in C++ as well?
From what I read so far in the other topics, it seems that I have to use a tool called CMake (again, isn't there a simpler way?). But I have no idea how to do that. What I did so far was:
I downloaded CMake installer and installed CMake
I downloaded xlnt zip file from GitHub and extracted it
I opened CMake GUI and:
a) as the source code folder I put this: C:/Users/Admin/Downloads/xlnt-master (this is the folder to wchich I extracted the zip file)
b) as the build folder I put this: C:/Users/Admin/Downloads/xlnt-master/build (I created the build folder after extracting the zip)
c) I clicked configure and left everything as default, except I changed the Visual Studio Version to 2019
d) I clicked generate and then I get an error message 'Error in generation process, project files may be invalid'. And it says this in the CMake Window:
'CMake Error at third-party/libstudxml.build/CMakeLists.txt:52 (add_library):
Cannot find source file:
C:/Users/Admin/Downloads/xlnt-master/third-party/libstudxml/libstudxml/parser.cxx
Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h
.hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc
CMake Error at third-party/libstudxml.build/CMakeLists.txt:52 (add_library):
No SOURCES given to target: libstudxml '
Another solution that I tried was finding the NuGet package called xltn and install it. After trying to compile the programme, though, I get two errors:
cannot open file 'xlntd.lib'
"link.exe" exited with code 1104

How to compile/build/link - the XLNT library?

I downloaded the xlnt library for working with Excel - https://github.com/tfussell/xlnt. Can you please tell me what to do with it further? Honestly, I still can’t understand how among all the files there are in the downloaded archive, and there are 100 of them .hpp and .cpp files, what should I do with them?
1)As far as I understand, they need to be processed by the Cmake program and it seems that the output should appear .lib file, but I absolutely can’t understand how to do it or maybe something else
2)Or how can they be directly processed by Visual Studio 2017?
PS:When I launch Smack, I select the Source folder, the Cmake generates many incomprehensible files, but among them there is not one file with the .lib extension.
Help me please.
With CMake you can obtain the visual studio 2017 project files
and then compile the xlnt library.
Unzip the archive file
Within the xlnt folder, create a new directory and call it build
Launche CMake (GUI)
Browse for the source code folder
Browse for the build folder xlnt/build
With the Configure button select the tool (IDE/compiler) that you want to use
Pressing the Generate button, CMake will generate (inside the build folder)
the visual studio 2017 project files you need to compile the xlnt library
Building the solution, VS 2017 produces the xlnt.lib, xlnt.exp and xlnt.dll files.
The source path you see in the CMake screenshot is incorrect. You must specify the path that contains the "top level" CMakeLists.txt file.
The correct directory is: C:/Users/Zver/source/repos/XLNT Library/xlnt-master.
The CMakeLists.txt file in the above directory tells CMake all necessary subdirectories.
At this point you will see the static compilation option of the library appear.
If you use the MinGW/GCC compiler you must prevent the path from containing empty spaces.
Then you need to rename the directory from "XLNT Library" to "XLNTLibrary". At this point the path would become:
C:/Users/Zver/source/repos/XLNTLibrary/xlnt-master.

Boost Library cannot get to work in C++, Include directories not working

I recently tried to install boost libraries in C++ 14, and I added it's include paths like:
Solution Explorer > Project Name > Property Pages > VC++ Directories > "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost"
I tried to compile after adding this:
#include <boost\variant.hpp>
In Error List window, I can see E1696 - cannot open source file "boost\variant.hpp" and I can't compile like before.
Then I tried with adding a backslash like "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\", still didn't work.
I also read this post and explicitly specified it's directory, but even didn't work.
Again, I read this post and did exactly same what is in given answer (as I already built project several times) , but still no success.
However, if I include a library like:
#include "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\variant.hpp"
Now compiler recognizes it, but now I can see more than 100 errors in Error List window, those errors are pointed to header files of boost libraries, not in my project file which has variant.hpp included.
All those errors are E1696 - cannot open source file "boost\<libraryname.hpp>" or E1696 - cannot open source file "boost\<subdirs>\<some other files included in libraryname.hpp>"
So, if I remove the line #include "C:\Program Files (x86)\Microsoft Visual Studio 14.0\boost\boost\variant.hpp" from my project's header file, all errors disappear suddenly and project compiles fine! no any single error now!
I want boost to work anyway, so I can use it in projects, but I can't manually edit all those header files and change <boost\... to original locations.
Please help me to get rid of this issue.
make sure you download and install the correct boost version. Installing it in the visual studio directories is possible, but not advised. I suggest you use one of the packages from here. Assuming you use visual studio 2017 and you are developing for 64bit, this could perhaps be the correct package for you.
make sure you do both: adding the include search path and the library search path to your visual studio.
The include search path should point to the boost-installation root directory (the one that contains the Jamroot file and a boost subdirectory). The library search path should point to the correct library subfolder within the boost installation. This is one of the subfolders that start with lib64-msvc-**.* (or lib32-msvc-* if you're developing for 32bit).
The default install path of the binary boost package above will install it into C:\local\boost_<boost version>. Make sure you use the paths from this installation directory and follow the instructions here.
Example:
Include search path: C:\local\boost_1_64_0
Library search path: C:\local\boost_1_64_0\lib64-msvc-14.1

Visual Studio 2010 Assimp library won't link

I seem to have a perpetual problem of never being able to get any library to link with Visual Studio. Ever. I eventually get tired of trying and just include the header and source files manually.
My latest endeavour is trying to set up Assimp. I went and downloaded the latest version and followed the installation guide for Visual Studio 2010. http://assimp.sourceforge.net/lib_html/install.html
The result:
LINK : fatal error LNK1104: cannot open file 'assimp--3.0.1270-sdk/lib/assimp_release-dll_x64/assimp.lib'
I set the include directories:
assimp--3.0.1270-sdk/include
I set the library directories:
assimp--3.0.1270-sdk/lib/assimp_release-dll_x64
I set the additional dependencies (the guide includes the directories, but shouldn't I just be able to just put assimp.lib since I included the library directory above?):
assimp--3.0.1270-sdk/lib/assimp_release-dll_x64/assimp.lib
What am I doing wrong?
Also, considering this isn't my first time having these difficulties, are there any good tutorials to help me understand this process a little better? I've tried searching for it but most are for previous versions of VS...
My guess is you should provide explicitly relative or absolute paths for the library directory.
You're right about the dependency name, assimp.lib is the correct name and the guide is a bit ambiguous here.
Apart from that, you're doing everything right. Provided the lib file exists, it should link.
(assimp co-founder writing here)

Build C++ Projects with Makefile using Visual Studio 2008

I downloaded cpptest from internet, and I want to build it using Visual Studio 2008.
The problem is that instead of .sln and vcproj file, Makefile.am is distributed, and I believe that all the all the necessary included file is included in the Makefile.am.
How to use Makefile.am to generate VS project files? I tried to use Cmake, but there is no CMakeList in the distribution.
Edit: Thanks to all the answers! There is a sln file distributed after all. But I am still interested to know the answer to my original question.
the visual studio project files for cpptest are in the win directory, not in the src directory where the makefile is..
edit
makefiles are meant to be used with GNU make. If you want that on windows, you can look at Mingw, GnuWin32 or Cygwin. But they also require gcc for compiling, so you won't really be using VS.
However, for most projects that do not have external dependencies it's no big deal if you do not have the VS project file: after all a makefile is just a list of the source files and some compilation options. To successfully build projects like cpptest, you could just create an emtpy VS project, add all source files to it, set output type to executable, build it and you're done. Eventually you can tune optimization options, but for the rest the default options will just do fine.
Go to win\VisualStudio.NET and you will find a VS solution file.
I just downloaded the archive and found the .sln file. It is under: /win/VisualStudio.NET. You can open that with VS2008 and update it, it should work.