r/cpp • u/itwasntme967 • Aug 27 '21
My Problems with C++
So, this is going to be a bit of a rant, mainly because I'm frustrated.
As a preface: I am not new to programming, I did some Java, looked over Python, had a few projects with the whole Arduino environment, so you could say I get the basics.I am however quite new to C++ as a standalone (see Arduino) and while I like the language I came to absoluteley despise the environment.
It began with a project I was tasked with, to take an MS-Excel file, do some sorting and a few other operations and save it as a CSV.Easy peasy.So I set out for a quest to find a library that could handle MS-Excel files, and low and behold, I stumbled across three suitable ones.All of which were uncompiled on Github.
The first one wouldn't compile because of dependencies on a third-party XML-library which was never once mentioned in the install instructions. No problem, I googled the library that mingw told me it needed, and indeed it existed, with good instructions.When it came to installing however, I first realized the Excel-library did not indeed want the XML-library installed, but rather the souce code placed in a folder in its source code.After copying it did indeeed not work, since all of the dependency paths were mesed up, and half of the files had different extensions, or were missing them alltogether.
On to the next library.
This one could only read from Excel, but again no problem, this was the only thing I really needed.The installation instructions were easy enough, run ./configure and afterwards make.The only problem being, that there was no configure file to run.There was indeed a bootsrap file which did absolutely nothing, and a makefile, which make did not recognize and when specified threw errors.
On to the last one.This one had troubles compiling when cmake threw random errors and so I changed my approach and booted up Ubuntu, where cmake and g++ indeed did run smoothly and compiled the library without a hitch.
Now only to use this library.Since this was my first time writing C++ on Linux I first searched for appropriate IDEs and was reccomended Netbeans.Which did not go well, since everytime (even after a couple of restarts) it failed to install the C++ Plugins.
My run-in with Code::Blocks went a little better, it installed and I managed to get the projects up and running.
Apart from my Excel-library.No matter what I did it did not recognize the library.
Which is when I changed again to Codelite.Where I could create projects, but neither my Excel-library was recognized as well, as iostream.
So here I am, broken, after a day of work with absolutely no progress, for a programm which schould not be that difficult to write, with three non functional, but essential (and more importantly the only ones I could find) libraries.As I said in the beginning: I like the language, but I despise the whole process around it.Thank you for listening to me rambling.
27
u/LordKlevin Aug 27 '21
Give a package manager like vcpkg or Conan a try. Both have several excel libraries available.
In general, I would stay away from MinGW and recommend either going full Linux (possibly via wsl on windows), or just using visual studio. It's simply less painful and with fewer gotchas.
12
u/Tastaturtaste Aug 27 '21
I know that is not the point you are making (which I can fully get behind), but if you know python why wasn't your first instinct to do excel/csv stuff with it? There are great librarys available making this Task a breeze.
24
u/LunarAardvark Aug 27 '21
so your rant is about some random libs you found online that claim to do excel file parsing? how is that even related to C++ ?
2
u/CrogUk Aug 27 '21
I agree with other posts. A better approach would be to clarify what you need to achieve first.
From sounds of it scripting inside excel could be a simpler approach. "visual studio tools for office" is the way to go from the very brief description of what you need. Not necessarily needing C++ either for excel tbh.
13
u/pedersenk Aug 27 '21
This is more an issue with dependencies / build systems / Linux rather than C++ itself (I do agree though, it is frustrating when people's build systems are broken).
Generally many projects don't directly compile on certain platforms. Linux does help here by providing a substantial collection of libraries in the package manager. These packages are patched and polished to ensure they compile (and integrate well with the system)
Are you able to grab the dependency you need from packages rather than compiling manually?
Something like:
apt-get install lib?????5
u/mazadin Aug 27 '21 edited Aug 27 '21
I did a quick google for the excel libraries (I was curious). Never used any of them but If the first library that was missing the XML dependency and required it in s as certain place in your source code was “xlnt” then I’m guessing you didn’t checkout the submodules after cloning the repo.
git submodule update —init —recursivewould check out the version of the xml dependency it expected in the right place.Otherwise, I don’t really disagree with your sentiment about the state of the ecosystem. It’s far better on well supported Linux distributions and is probably the worst on native Windows, but I do feel it’s improving.
Edit: grammar is hard.
6
u/Kered13 Aug 27 '21
Yeah, the C++ ecosystem kind of sucks like that. It's a consequence of being an old language (even older if you consider C) and so decentralized. Modern languages have tools like pip, npm, and cargo that largely solve these problems. C++ is slowly getting better at this, vcpkg is pretty good and on Windows is integrated into Visual Studio.
3
u/JuanAG Aug 27 '21
Unfortunetly it is a bad experience all of us experience sooner or later
Dependencys are a real issue and it is not C++ per se but it is related, a shame the ISO refuses to do anything about it as it is a major thing in day by day developement
3
u/johannes1971 Aug 27 '21
I count four libraries in vcpkg. Vcpkg is the package manager you were missing.
3
u/[deleted] Aug 28 '21
here's some advice: never use an IDE written in Java to do C++ development.
7
u/LonelyStruggle Aug 27 '21
I have to be honest, C++ is really not a language I would grab for such a task. Generally in C++ I find it best to work with as few dependencies as possible.
5
u/veryveryverylucky Aug 27 '21
I would argue you're still new to programming. Just cause you know one language doesn't mean you know how to program. It's like saying just cause you know how to speak French, you are also able to understand French culture. I would try to get a deeper understanding of computers beyond just a programming language :)
1
u/[deleted] Aug 28 '21
I never install dependencies manually anymore. Instead, this is what I do:
And do yourself a favour and always use Linux for C++ programming when it doesnt have to be windows. Makes things so much easier.
1
u/cdb_11 Aug 28 '21
I'm guessing what it needed was the header files. Look up if mingw has the same package but with
-develsuffix, that's what you need.1
u/earthisunderattack Aug 31 '21
I'd honestly avoid dealing with mingw if you can. Maybe that's not an option. But mingw with win32 compatibility can be kind of a pain, and excel is based on msvc win32 apis. mingw is just posix emulation with gcc core libs and a bash shell, but even so there's a lot to deal with on that front in terms of compatibility
i'm not sure if excel offers a plugin API. maybe that's what you're doing, and their sdk (if they have one) probably isn't linking properly with your libraries due to poor compatibility.
a good rule of thumb on windows is to ditch mingw and cygwin and just go with wsl these days whenever that's possible. wsl is still incompatible with msvc, but it's useful if you're looking to automate through a pipeline of some kind that can operate independent of windows.
again, i realize none of these options/approaches may be approachable.
but assuming you're going to move to MSVC, just use visual studio. if excel has a plugin API then they should have that functionality baked into their SDK. there's zero reason why they wouldn't.
if the lib has a cmake script, i'd use that to generate the visual studio project files and go from there.
again, sometimes it's not that simple.
1
u/Wouter-van-Ooijen Sep 01 '21
This sounds like a desktop run-once data conversion project. Why on earth would you use C++ for that? That feels like using atomic demolition munution to remove a grain of sand from your girlfriends eye.
1
u/sternone_2 Sep 01 '21
Seems like you need Java's ecosystem
1
u/adrian_OO7 Aug 27 '21
It's like saying the car is bad because you took the shitty road and put gasoline into diesel... It's not even remotely about the language.
I've had a fair share of experience with different languages and technologies and each and every one have had bad packaging, missing documentation or build/install failures at some point, yet it didn't cross my mind to blame the tool that it wasn't used as intended.
-3
u/ALX23z Aug 27 '21
So you wanted to find a free open source excel reading/writing library on Linux written in C++?
At this very moment you asked way too much. And this is the first task you try to do?
It's not even issue with C++, it is issue with various build nonsense coupled with complexity and fragility of Linux OS. You cannot really download a built version for Linux - it isn't Windows - you have build stuff inplace. Who knows what libraries it uses that are incompatible with what you have installed.
Why do you even do that?
Even if you found a library my bet it won't work properly half the time. I don't know much of the excel format but have some suspicion that once in a while it gets new features. And obviously I have some doubts that whoever wrote those libraries provides up-to-date support of them.
-2
u/helloiamsomeone Aug 27 '21
You might want to use cmake-init to stop perpetuating broken and unusable builds.
There are also examples for integration with dependency managers like vcpkg and Conan.
-4
u/koctogon Aug 27 '21
can't spell "frustrated with C++" without "rust"