How to solve comiler error: 'v_bias' is not a namespace-name - c++

Sort briefing what I am trying to do:
I want to use vnode-lp on my windows PC. I’ve installed MinGW. I’ve installed the necessary dependencies like LAPACK & BLAS libraries as well as Profil/BIAS. The installation of all libraries passed the make and make install process without errors. I hope (!) I’ve managed to install it correctly.
Now the Problem:
Now I’ve tried to get a simple program compiled with basically northing in it just an #include “vnode.h”. First I tried it with Microsoft Visual Studio. Since this gave me several errors I tried to compile it with g++ using MinGW. This gives me the same errors. It starts with
./matrix.w:90:17: error: ‘v_bias’ is not a namespace-name
The Question:
How to include vnodelp into an c++ program and compile it without errors under windows, am I missing something?
Off-topic:
I am trying to get this running for over a week now and don’t know what to do anymore.

C++ is most definitely not C, and packages designed for C++ will never compile and run as C code. So, what you're trying to do really can't be done unless you do some fancy stuff by creating a .dll or something like that, and even then I think you wouldn't get the functionality you want. Why not write your code in C++ and compile with g++ or a similar compiler?

I have managed to finally solve this issue. In case someone has the same problem here is the solution.
I have missed something in the call. Here is the full call that has worked for me:
g++ -o2 –Wall –Wno-deprecated –DNDEBUG – DPROFIL_VNODE – DMAXORDER=50 –I(path to profil bias)/include –I(path to profil bias)/include/BIAS –I(path to profil bias)/src/Base –I(path to vnodelp)/FADBAD++ -I../include –DNDEBUG –c –o (filename).o (filename).cc
g++ -L(path to profil bias)/lib –L(path to lapack)/lib –L../lib –o (filename) (filename).o –lvnode –lProfil –lBias –llr (path to lapack)/lib/liblapack.lib (path to lapack)/lib/libblas.lib –lstd++
funfact:
This also complies with gcc instead of g++

Related

My Boost #includes cause compile failure (reformulated)

When I try to #include boost 1.60 headers, gcc fails. I'm at a loss because of this and would be appreciative of any help/guidance. I am using Fedora Linux and Netbeans 8.2.
This question was originally posted under user:user11551798, for which I don't have a password since it was posted from my mobile app.
Code snippet:
#include <boost/regex.hpp>
#include <boost/xpressive/xpressive.hpp>
#include <boost/asio.hpp>
(all three fail within the #includes)
Compiler call (from Netbeans)
gcc -O ALAN ALAn.gcc
Errors (sample from asio.hpp)
g++ -g -m64 -lboost_system -c -o ALAn.o ALAn.cpp ALAn.cpp: In
Function »int main(int, char**)«: ALAn.cpp:57:23: Error: no matching function for call to
»boost::asio::ip::basic_resolver<boost::asio::ip::tcp>::basic_resolver()«
ip::tcp::resolver resolv;
^~~~~~
Compiler error displayed means "No available function"/"Unmatched external symbol".
As always, thank you for any assistance, Im currently at a loss. And of course, sorry in adv for any transgressions. Im new here.
#yksisarvinen, #Mathieu
I now installed the Boost V1.71 lib. Same problem :-(
The enlightenment came after I upgraded Boost from V1.60 to V1.71 and my problems persisted. I was sure that I had deleted the old files with rm -vf.
So I looked at this closer.
It sure was not sync(1) because some problems persisted after syncing.
I looked at the GCC tools, which I use (this is Linux). It turned out that it HAS a little known (to me) compiler cache utility, CCACHE(1).
So I cleared the compiler cache, ccache -c. This made visible that the Boost lib tool does not compile some headers for some sui-generis reason, including regex and xpressive, which I use.
So I corrected that and Voilá! everything worked :-)

Mingw64 Linker error when trying to include -lhid [duplicate]

Context: I'm using Qt 5.9.3 on Windows, building for MinGW 32-bit. The Qt part is a side issue though - the problem seems to be with MinGW. The version of MinGW is 4.3.0, supplied prebuilt as part of the Qt installation.
I'm building a library which talks to a USB device over HID. Everything compiles fine, but it fails at the link stage with
./..\..\object\debug\usb_hid_device.o: In function `ZN8MyApp3USB5Win3213getDevicePathB5cxx11Ell':
<MYPATH>/../../source/win32/usb_hid_device.cpp:99: undefined reference to `HidD_GetAttributes(void*, _HIDD_ATTRIBUTES*)#8'
./..\..\object\debug\usb_hid_device.o: In function `ZN8MyApp3USB5Win3214CHIDDeviceImplC2EllRNS_15LogPerComponentE':
<MYPATH>/../../source/win32/usb_hid_device.cpp:200: undefined reference to `HidD_FlushQueue(void*)#4'
The linker command is
g++ -shared -mthreads -Wl,-subsystem,windows -Wl,--out-implib,<MYPATH>\bin\debug\libusb_hid_comms.a -o <MYPATH>\bin\debug\usb_hid_comms.dll object_script.usb_hid_comms.Debug -lhid -lsetupapi -LC:\Qt\Qt5.9.3\5.9.3\mingw53_32\lib C:\Qt\Qt5.9.3\5.9.3\mingw53_32\lib\libQt5Guid.a C:\Qt\Qt5.9.3\5.9.3\mingw53_32\lib\libQt5Cored.a
If I omit -lhid I get the same errors. I also get the same errors if I remove -lhid and explicitly set the path and filename to libhid.a. If I deliberately mistype the path and filename, it comes up with an error, so I know the command-line is getting parsed correctly. But for whatever reason, MinGW appears to not be linking with one of its own library files.
I've also tried removing -lsetupapi and I get the linker errors I'd expect for the functions defined in there. Likewise the Qt library files. But it seems that specifically for libhid.a, MinGW can see the library file but just isn't going to link with it.
Has anyone else seen this? Or can anyone else with the same (or similar) version of MinGW confirm or deny that they can link with libhid.a? Or is there something obviously wrong with what I'm doing?
I've just found the answer. I'm posting an answer myself so that other people know in future, because I think this is still a valid question which people might want to know about.
The problem is the include file hidsdi.h. The majority of other header files which pull in Win32 API calls have extern "C" around the function declarations. However this one doesn't! The result is that we end up with C++ name mangling for linker symbols, instead of the C-style "_" in front of the linker symbols.
The solution is to use
extern "C"
{
#include <hidsdi.h>
}
and then everything works fine.
The version of hidsdi.h with the older version of MinGW (which I'm porting from) did have that protection around the function declarations. However it looks like it's gone in the newer version.

error: ‘fileno’ was not declared in this scope

I am running Cygwin on windows 8, attempting to compile the source code for a game I would like to mod. Unfortunately I am running into some errors while building involving the fileno function. After doing some googling It seems like the problem might have to do with c++11 support (I'm not really sure what this means). Most of the solutions people have found involve adding some option like -std=c++0x or -std=c++11 when compiling, but my attempts to add the options into the makefile have been unsuccessful, and I don't know if that's whats causing the problem anyways. I'll include the code snippet that's throwing the error and a link to the makefile as it is quite large. Any advice you could give me would be great.
code that throws error:
time_t file_modtime(FILE *f)
{
struct stat filestat;
if (fstat(fileno(f), &filestat))
return 0;
return filestat.st_mtime;
}
Link to Makefile
it is being hosted on github
EDIT: After getting some advice I poked around the makefile and found five instances where the -std option was used, playing around with them hasn't changed anything. Is the problem with my Cygwin configuration? I installed the packages I was told I would need in the installation guide for the game I am building.
Changing the -std=c*** in your makefile to -std=gnu++0x should fix your problem.
If you don't know what c++11 is you're most likely not using it anyway.
Also if you need c++11 support you can also do: -std=gnu++11 instead of -std=gnu++0x
For windows...
fileno() is deprecated: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/posix-fileno?view=vs-2017
use _fileno() instead: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fileno?view=vs-2017

Using C++ MySQL Driver on Windows

The actual error is a linker error. Undefined reference to get_driver_instance.
Any ideas what the problem is?
This is what I did to install.
Download and install MinGW to C:\MinGW. http://www.mingw.org/
Download boost and move the boost folder to C:\MinGW\include
Download Connector/C++ 1.1.3 http://dev.mysql.com/downloads/connector/cpp/
Move the mysql_connector/include/*.h (recursively) to C:\MinGW\include\
Move the mysql_connector/lib/mysqlcppconn-static.lib to C:\MinGW\lib\libmysqlcppconn-static.a
Move the mysql_connector/lib/mysqlconncpp.dll to C:\MinGW\lib\mysqlconncpp.dll
Alter cppconn/config.h to remove dupication
Copy the C++ example and name it test.cpp http://dev.mysql.com/doc/refman/5.1/en/connector-cpp-examples-complete-example-1.html
add "using namespace sql::mysql" to the file (as recommended)
run "g++ test.cpp -L C:\MinGW\lib -l mysqlcppconn-static"
It's likely in a namespace.
throw in this and see what happens:
using namespace sql::mysql;
edit: Also, did you look through the approximately 869 other times people have asked this same question on stack overflow before posting?
https://www.google.com/search?q=mysql+get_driver_instance+site:stackoverflow.com
If that isn't it, it can be a problem with c++ name mangling.
https://en.wikipedia.org/wiki/Name_mangling#Name_mangling_in_C.2B.2B
Because the name-mangling systems for such features are not standardized across compilers, few linkers can link object code that was produced by different compilers.
and I think the final answer is here:
http://www.mingw.org/wiki/MixingCompilers
another stack overflow answer saying this:
What problems can appear when using G++ compiled DLL (plugin) in VC++ compiled application?
You'll need to build the connector from source using your g++ compiler:
http://dev.mysql.com/doc/refman/5.1/en/connector-cpp-installation-source.html

gnuplot-iostream won't compile

I was wondering if someone could help me with this.
I've retrieved the source code for the gnuplot-iostream interface from http://www.stahlke.org/dan/gnuplot-iostream/. However, when I attempt to compile the code using the command:
]$ cmake .; make
I get the following compiler error
/.../gnuplot-iostream.h: In constructor ‘Gnuplot::Gnuplot(const std::string&)’:
/.../gnuplot-iostream.h:427: error: ‘never_close_handle’ is not a member of ‘boost::iostreams’
I'm using Scientific Linux 6.2 (kernal 2.6.32-220.23.1.el6.x86_64), g++ 4.4.6, and have boost libraries installed (/usr/include/boost/iostreams/ exists).
Any assistance would be very much appreciated.
D
enum file_descriptor_flags was added in boost::iostreams only in 1.44.0.
enum file_descriptor_flags
{
never_close_handle = 0,
close_handle = 3
};
So, the solution is simply update the boost library (thanks ForEveR).
If however, like me, you do not have the access to update the libraries on your system you should note that I was able to force compilation and obtain basic functionality by simply replacing the two occurrences of boost::iostreams::never_close_handle in the gnuplot-iostream.h file with 0.