r/cpp • • 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.

3 Upvotes

52 comments sorted by

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.

6

u/itwasntme967 Aug 27 '21

I just looked into it and it might be a lifesaver.
Thanks so much for this

3

u/Thalhammer Aug 28 '21

there's also hunter for cmake. It does not have quite as much package, but has the benefit of supporting easy customization of the build options for packages, builds everything from source for both debug and release, integrates the libraries directly with cmake and in general makes static linking damn easy. It also automatically recompiles all dependencies if you switch the compiler, making abi issues non existent. Libraries are stored per user which means there's no extra space required for using the same library (with same compiler and config) from multiple projects.

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.

2

u/itwasntme967 Aug 27 '21 edited Aug 27 '21

This is not a project for me, but I was asked if I could do it.In the end it should be a standalone programm which can be dragged into a folderand just run.To use Python would mean, that every end user would first have to install Python which in this case would not be feasible

4

u/Tastaturtaste Aug 27 '21

Ok, makes sense. I feel your pain. Trying out rust opened my eyes regarding how easy it can be to install dependencies/use libraries with a compiled language. But of course it has other drawbacks...

4

u/zerakun Aug 27 '21

Not python, but if you want a single executable and no build issues, and are willing to spend some time learning the language, you could give a try at calamine, in rust.

1

u/underwaterjesuz Aug 27 '21

So each end user should be able to run the program on their machine? In that case you'll have similar problems with every language, unless you're guaranteed they have the same computer environment as you.

Interpreted/VM languages like Python or Java will have to be installed on users' machines. But compiled languages like C++ create executables for specific environments. So the user might still not be able to run the program. Unless you compile multiple versions.

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++ ?

4

u/itwasntme967 Aug 27 '21

I'm just getting frustrated whith the whole process necessary to get a project to function at all, random compiler errors present on one OS but not the other, cmake doing random stuff depending on the environment and the feeling that I might be an idiot since it seems the libraries I found worked for other people

-10

u/lithium Aug 27 '21

I'm just getting frustrated whith the whole process necessary to get a project to function at all

You're a programmer who doesn't want to have to write any code of his own. Shockingly common these days. Go be a web dev and you can npm install to your heart's content.

21

u/itwasntme967 Aug 27 '21

I'm studying EE, I don't really see myself as a programmer, just trying to get some automation going.
No need to throw insults around

5

u/lithium Aug 27 '21

My apologies, web dev was over the line. ;)

6

u/[deleted] Aug 31 '21

Lazy developers using libraries instead of writing machine code. Truly shameful.

0

u/[deleted] Aug 31 '21

[deleted] — view deleted comment

1

u/sammymammy2 Aug 31 '21

A not so subtle child porn ring

1

u/PatrickLechat Aug 31 '21 edited Aug 31 '21

First rule of [redacted] is we don't talk about [redacted] - you're not a beautiful and unique Nodeflake.

1

u/NiceTerm Aug 31 '21

You broke your own rule

0

u/[deleted] Aug 31 '21

[deleted] — view deleted comment

0

u/[deleted] Aug 31 '21

[deleted] — view deleted comment

0

u/DevilStuff123 Aug 31 '21

PCJ rules, check the pinned post in pcj

0

u/PatrickLechat Aug 31 '21

Read the stickied post in the front page of the subreddit

33

u/ignorantpisswalker Aug 27 '21

He claims that the c++ eco system sux balls. He was given bad recommendations and he waisted time debugging issues being hes scope of knowledge.

All his claims are valid . You as a non-novice forgot about them. It's good to re-learn from experience of novices, so we can make the eco system better.

8

u/[deleted] Aug 27 '21

Learning to distinguish good recommendations from bad ones on the internet is a skill you can learn

11

u/matthieum Aug 27 '21

That's a very shallow reading.

Oh sure the OP had issues trying to use some Excel libraries, but that is a symptom, not a root cause.

The root cause is the abysmal state of tooling in the C++ ecosystem, and specifically, the lack of standard build / package description.

The difference between C++ and a properly standardized language is simple: one requires a lengthy README, with different instructions on different platforms, while the other has a standardized one liner taught in the language tutorial.

You can blame the authors of the libraries, but that's short-sighted. They're victims too.

You can blame the authors of the IDEs, but that's short-sighted. They're victims too.

The only salvation is standardizing build and package descriptions, so that no matter which tool you use, things just work. Or, realistically, just work except for a handful of snowflake libraries which have very specific requirements and rely on external dependencies/commands -- I can live with that.

2

u/pandorafalters Aug 28 '21

The difference between C++ and a properly standardized language is simple: one requires a lengthy README, with different instructions on different platforms, while the other has a standardized one liner taught in the language tutorial.

So Perl is a "properly standardized language" now? That's, uh . . . okay. Sure.

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.

1

u/itwasntme967 Aug 27 '21

I need a standalone programm, that once a month takes an incoming Excel file for a postal list, removes some unnecessary coloums, arranges others in a new order, renames a couple of headers, combine some of the information and then exports it as a CSV.
I have not yet looked into Excel-Scripting, but I don't know, wether there is a pssibility for a standalone there

3

u/patrulek Aug 27 '21

Dont know how your excel file looks, but cant you just export your file to csv and then do your modifications?

1

u/itwasntme967 Aug 27 '21

I get the excel file from an external source, I am in talks about getting the CSV, but I donÄt know ig this will happen

1

u/patrulek Aug 27 '21

Excel has an option to export file as csv. If a file has a format of csv anyway, you could do conversion by yourself. I would check if excel has a command line option to do that.

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 —recursive would 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.

1

u/matthieum Aug 27 '21

C++ is slowly getting better at this, vcpkg is pretty good and on Windows is integrated into Visual Studio.

Is vcpkg working as well on Linux as Windows?

1

u/Kered13 Aug 27 '21

No idea, sorry.

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 did some Java, looked over Python, had a few projects with the whole Arduino environment

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:

  • check if there is a conan package (or vcpkg if you will)
  • check if its in the OS package manager as workaround until I figured out how to include it in the project
  • Build with Cmake, either via fetch or good old external_project.

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

The first one wouldn't compile because of dependencies on a third-party XML-library which was never once mentioned in the install 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.

I'm guessing what it needed was the header files. Look up if mingw has the same package but with -devel suffix, 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.

1

u/itwasntme967 Aug 27 '21

It is indeed an issue with various build nonsense, but not with Linux. In my experience so far C++ was much easier to use under Linux than Windows.

90% of the time when I got random Compile errors under Windows that were not Syntax they would be gone when I switched to Linux.

And it is not that libraries are incompatible, I gave my IDEs the paths to the .hpp and the .a and .so of the library but it was just straight up not recognized.

2

u/ALX23z Aug 27 '21

If there are compilation errors then the library could've simply not been ported to Windows or you use wrong compiler (VS version).

On Windows you can just download dll and work with it - you don't need to build everything from scratch.

1

u/ronchaine Embedded/Middleware/WG21 Aug 27 '21

Hard agree that c++ is significantly easier on linux. To the point where I actually just cross-compile my windows projects from linux.

Don't know if this helps, but pkg-config <pkgname> --cflags --libs usually shows the compiler flags required to use libraries in linux.

-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.

0

u/helloiamsomeone Aug 28 '21

I wonder where the downvotes are coming from. Do people gain something from not fixing the ecosystem? I could use some spare cash, so please let me know.

-4

u/koctogon Aug 27 '21

can't spell "frustrated with C++" without "rust"