How do I link a library in VSCode? - c++

I'm trying to include curses.h and some functions from that lib (specifically detecting a keyboard hit without stopping), but whenever I try, it gives the error "symbols not found." I'm assuming that this is because the clang++ compiler sees curses.h as a C library. I've gathered I need to link curses.h, but I don't know how and I could not find any real guides.
I'm writing a program in C++ using VSCode and clang++ on a mac. Any help is appreciated.

For anyone else who has this problem- my clang version was outdated. It was installed, so after a brief check, I thought all was good. However, it was not able to compile (nor find some libs for some reason) the newer versions of C++. Installing the latest version of clang fixed all issues.

Related

How can I specify C++ standard version in DPC++ compiler options?

I stumbled upon free stuff in the form of Intel oneAPI toolkit and everything works great, the samples compile fine but I don't know how to specify the C++ standard in the compiler options. From what I understand DPC++ is built on top of Clang so I should be able to choose which C++ version it compiles for but I don't know how.
How do I get my C++17 code to work?
This is an ongoing issue, there are reports of other users with the same issue. As far as I know it hasn't been solved yet, what you can do meanwhile is to run the program from the command line:
Go to the folder where you installed OneApi, let's say C:\Program Files (x86)\inteloneapi\ and run setvars.bat to set environment variables.
Then compile the program using the C++17 flag, navigate to the folder where the source code is and run dpcpp filename(s).cpp -std=c++17.

How do I compile peercoin to generate windows binaries?

I have been trying to compile peercoin (https://github.com/ppcoin/ppcoin) for windows and have failed so far.
The Linux one compiles on Ubuntu perfectly and most forums suggest using the compiler on Linux to generate windows binaries. I have never heard or using linux compiler to generate windows binaries.
So the question is : How do I compile the peercoin source for generating windows binaries?
Thanks
Edit: I tried the ming libraries as mentioned in the makefile but there are multiple compile time errors including non-descript errors like "unable to find matching '" etc.
Bounty for step by step explanation for generating the windows binaries (on Unix or Windows)
Found the answer. The problem is that paths for mingw cannot end in "\" apparently. So my paths "c:\mingw-32" is perfectly fine but "c:\mingw-32\" throws an unable to find matching quotes error.

Why can't Eclipse find regex on Mac OSX?

I'm using Eclipse Juno on OSX Mountain Lion and wanted to use std::regex, which I know is a C++11 only feature. When I #include <regex> the IDE says it doesn't exist. Maybe it's good to note that the header regex.h is present /usr/include/, though I see no specific library for it in /usr/lib/ or /usr/local/lib/, though I'm not aware if that's relevant. This is just a side project for fun so I'm not using a customized build system, just a regular C++ project in Eclipse.
I'm not real experienced when it comes to modifying a build process (other than setting include paths, libraries, etc.), especially when an IDE like Eclipse is driving it, but my assumption is that the compiler and linker (GCC G++) isn't configured for C++11, though I've tried various recommendations from SO and the Eclipse forums, like adding -std=c++11, but I just keep seeing output saying that they're unrecognized arguments.
I'm sure someone out there has dealt with this issue. Can anyone help? Thanks in advance.
On mac you have to use the flag:
-stdlib=libc++
and even then I believe generally only clang is updated enough(so use clang instead of gcc), if you've just been using the Xcode updates. You should also make sure that your Xcode command line tools are updated, because I would guess that is the compiler eclipse is using.

boost asio giving You must add -D__USE_W32_SOCKETS to your compiler options on cygwin

I was trying to use the boost library first time. Using as an environment Eclipse 4.3 with CDT and as compiler gcc 3.4 and boost 1.53.
I was browsing various sites to find info on how to setup boost, but it doesn't seem to work. When I compile trying to include boost/asio.hpp I get the error:
You must add -D__USE_W32_SOCKETS to your compiler options
However, I don't want to use windows sockets, I want to use posix, so I don't really know what is wrong. As I need the project to run on HP-UX later, I dont want to get to Windows specific. If I use now windows sockets will the program later be easily portable to Unix, or are all the details encapsulated in boost, and I don't have to care anyway?
I tested a simple testprogram using FOREACH loop to confirm that boost itself works, and this is the case.
I also found this: https://svn.boost.org/trac/boost/ticket/7881 so does it mean that this problem is currently currently not supported, or am I doing something wrong?
It seems what you're trying to do is not supported by the library, the documentation states the following under supported platforms
The following platforms and compilers have been tested:
Win32 and Win64 using Visual C++ 7.1 and Visual C++ 8.0.
Win32 using MinGW.
Win32 using Cygwin. (__USE_W32_SOCKETS must be defined.)
Linux (2.4 or 2.6 kernels) using g++ 3.3 or later.
Solaris using g++ 3.3 or later.
Mac OS X 10.4 using g++ 3.3 or later.
added emphasis is mine. If that's not possible, you might try the patch suggested in the linked ticket. However, grepping through the source code I see several occurrences of #if !defined(BOOST_WINDOWS) && !defined(__CYGWIN__) so it's not obvious that simply patching io_service.hpp will resolve anything. You might try adding -U__CYGWIN__ to your CXXFLAGS, though the cygwin toolchain may not like that.
Full disclosure: I am not a Windows guy so hopefully someone else will chime in.
The libboost-devel package in the Cygwin distribution includes patches to not use Winsock on Cygwin in Boost.Asio. I suggest trying that in conjunction with the gcc4 packages, which provide more recent versions of GCC.

How to compile V-USB for arduino?

Simply put, I downloaded a port of V-USB for Arduino and can't seem to compile the example that came with it. I get the following message when trying to compile using Arduino IDE 1.0.1
avr-gcc: error: unrecognized command line option '-assembler-with-cpp'
I understand that this is most likely version incompatibility issue and could be avoided by downgrading my avr-gcc to an older version, but is it possible to do some trick to make it compile using the up to date version of avr-gcc?
Just a few notes about environment I'm trying this on
OS: Fedora release 17 (Beefy Miracle)
avr-gcc: (Fedora 4.7.2-1.fc17) 4.7.2
Arduino IDE: (arduino-1.0.1-1.fc17) 1.0.1
The -assembler-with-cpp option instructs the compiler to consider all following files to be assembler files requiring preprocessing. From a quick glance in v-usb, they provide .asm wrappers for .S files. You don't need to use those and the compiler will recognize the .S files automatically without any options.
If the problem isn't with the .asm wrappers detailed above, you can rename the files in question to .S.
Have you tried compiling without the flag? What happened?
With the hints from Jester I managed to solve this problem by updating the IDE to version 1.0.3 (1.0.2 might work as well) and it worked like a charm.
So I guess the problem wasn't the code or compiler, the problem was that the IDE 1.0.1 was expecting an older version of the avr-gcc and used a deprecated flag for compiling and simply failed since that flag is no longer available on the new compiler so you either have to downgrade the compiler or upgrade the IDE and from my perspective, upgrading is always the right choice to make.