Issue with executing .exe written in C++ (using mingw compiler) - c++

I am new to programming and trying to learn C++ using C++ Primer (5th ed.). I have written this code that is directly from the book. The issue is when trying to execute the .exe results with this prompt popping up
The procedure entry point _ZNKSt9basic_ioslcSt11char_traitslcEEcvbEv could not be located in the dll
The .cpp
#include <iostream>
main ()
{
int sum = 0, val = 0;
while (std::cin >> val)
sum += val;
std::cout << "The sum is: " << sum << std::endl;
return 0;
}

Take a look at the directory where your mingw compiler is installed.
Within the "bin" directory you should finde several "*.dll" files like "libwinpthread-1.dll", "ligstdc++-6.dll" and so on...
These libraries are required to execute your application since mingw needs some platform wrapping magic (its a port of gcc for linux).
Try to copy these dll's into the same folder of where your "*.exe" is located.
If this does not help:
The error message is a bit confusing since I would expect it to report a dll file is missing instead of a missing procedure. In this case it looks like your compiler installation is broken or as already mentioned your build environment is not correctly set up. Which mingw version are you using, where did you get it from?

Related

The procedure entry point "_ZNSt7__..." could not be located in the dynamic link library. Anyway to solve without copying the .dll to every folder?

I've started going through Principles and Practice using C++ 2nd edition recently and I've run into a problem with Chapter 3.
Trying to run the example
// Read and Write a first name
#include "std_lib_facilities.h"
int main()
{
std::cout << "Please enter your first name (followed by 'enter')\n";
string first_name;
std::cin >> first_name;
std::cout << "Hello, " << first_name << "\n";
return 0;
}
Leads to the error:
"The procedure entry point
_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1Ev could not be located in the dynamic link library"
The code compiles (Using G++) fine but running the resulting .exe throws that error. After doing a short search I've found that copying the "libstdc++-6.dll" from MinGW into the folder works to solve the issue. But I was wondering if it's possible to set it up so I don't have to copy that .dll into every folder I'm using. After some searching I thought it was to do with my PATH and having MinGW's directory come before Sys32 (Like this) but trying that did nothing.
If it helps I'm using this verion of the std_lib_facilities.h file.

Problem with WFDB library in C++ project (undefined reference)

I am trying to link PhysioBank data to my Qt program in Windows 7. I followed the instruction from PhysioNet website and WFDB programmer's guide to install the package in MinGW, and tried to link the library to a simple testing program as suggested in the guide (as below). However, problems show up no mater I try with either Qt creator or Dev C++.
As suggested in the guide (p. 9), I copied curl and wfdb folders and headers to the Visual C++ directory that contains "stdio.h", and include signal.c and wfdbio.c as source files. But eventually the Qt compile error message says that "inttype.h" is not found. I guessed this is because Qt uses Visual C++ compiler but not suggested gcc, and required headers are different. But when I turn to try with Dev C++, which uses gcc 4.9.2, other errors still show up, like: "undefined reference to _imp__curl_version". Is this because the compiler is still somewhat different from that used by MinGW? If my guess is right, how could my work be possibly done?
Sorry for any beginner's mistake. Thanks very much for kind reply!
#include <stdio.h>
#include <wfdb/wfdb.h>
int main(void)
{
int i;
WFDB_Sample v[2];
WFDB_Siginfo s[2];
if (isigopen("100s", s,2) < 2)
exit(1);
for (i = 1; i< 10; i++){
if (getvec(v) < 0)
break;
printf("%d\t%d\n",v[0],v[1]);
}
exit(0);
}

Reference Abaqus C++ API static libraries to read ODB files

I have Abaqus CAE, Visual Studio 2017, Visual C++ compiler installed in my computer. I'm trying to reference Abaqus CAE's static libraries in my Visual Studio C++ project to read my ODB file.
This is the code file that I'm trying to compile & execute :
```
#include "pch.h"
#include <iostream>
#include <odb_API.h>
#include <odb_String.h>
#include <odb_Repository.h>
using namespace std;
int main()
{
cout << "Initializing API"<<endl;
odb_initializeAPI();
odb_String odbFilePath = "C:\\Users\\Dularish\\Desktop\\Temp_Toclear\\Job-1.odb";
try
{
odb_Odb& odb = openOdb(odbFilePath);
odb.close();
}
catch (odb_BaseException& ex)
{
cout << "Exception message : " << ex.UserReport().CStr() << endl;
}
catch (const std::exception& ex)
{
cout << "Default Exception message : " << ex.what() << endl;
}
cout << "Hello World!\n";
odb_finalizeAPI();
return 0;
}
```
Visual Studio Project Settings :
Platform : X64 (I'll not be able to compile with X86)
Configuration Properties > VC ++ Directories > Include Directories : C:\SIMULIA\Abaqus\6.14-3\code\include;$(IncludePath)
Configuration Properties > VC ++ Directories > Library Directories :
C:\SIMULIA\Abaqus\6.14-3\code\lib;$(LibraryPath)
Configuration Properties > Linker > Input > Additional Dependencies :
ABQDMP_Core.lib;
ABQSMAAbuBasicUtils.lib
.... and all the rest of the files present in the directory "C:\SIMULIA\Abaqus\6.14-3\code\lib".
With these settings, I'm able to compile it without any errors, but on execution of exe application,
I'm getting the below error :
"The procedure entry point ?openOdb##YAAEAVodb_Odb##AEBVodb_String##_N1VSMABasStringMode###Z could not be located in the dynamic link library ABQSMAOdbApi.dll"
Error Screenshot
Does it mean that I'm missing a static library containing openOdb method?
I'm trying to connect with people who are already familiar with Abaqus ODB C++ API who could help me on this.
Thanks.
Edit 1 : I don't want to use abaqus make utility because I want to build my own postprocessing application based on .NET platform. The lines "odb_initializeAPI();" and "odb_finalizeAPI();" are the lines which should be used if I want to access Abaqus ODB API outside Abaqus CAE. I'm actually following this page from the scripting documentation "http://130.149.89.49:2080/v2016/books/cmd/default.htm?startat=pt05ch10s07.html"
The other resource that guided me to use this approach : "https://www.reddit.com/r/fea/comments/8oqx5x/setting_up_abaqus_c_interface/"
There are at least two issues with your solution and approach:
The program you write must not contain a C++ main routine, aka the function main. Instead, the entry point for the program must be a function named ABQmain, having the same signature as the regular function main.
You must compile your Abaqus C++ code using the Abaqus make utility. Once you have finished writing your code and would like to compile it, the correct command to use is:
abaqus make job=your_code.cpp
If you have Abaqus on your machine, then you should also have the documentation. The section "Abaqus Scripting User's Guide" contains a section "Using C++ to access an output database." There you can find some examples and the details I've pointed out here. It should be a good starting point for your work.
EDIT: After pointing out that you wish to use the Visual Studio for development and compilation, make sure to check the system requirements for the Abaqus version you are using. Try to use the same Visual Studio C++ compiler as the one used for compiling Abaqus. Simulia is most probably using an older version of the Visual Studio C++ compiler than you are.

MinGW completely bugged on NetBeans

The following code shoudn't produce an error:
#include <cstdlib>
#include <cstdio>
#include <iostream>
using namespace std ;
int main ( int argc , char** argv )
{
int n ;
cin >> n ;
cout << n ;
return 0 ;
}
Yet a get a "RUN FAILED (exit value -1,073,741,511, total time: 46ms)" whilst running MinGW/Msys on Netbeans. Any advice like switching back to Cygwin?
I recommend using MinGW Distro if you want to develop C++ under a Microsoft Windows operating system. It ships with a pretty new GCC version and with the Boost libraries.
NetBeans IDE is pretty picky regarding the build environment settings. E.g. It doesn't work together with all versions of make (we have to distinct make.exe from MSYS and mingw32-make.exe from MinGW for example) and there are problems regarding the used Java Runtime Enviroment (JRE).
With the settings shown in the following screenshot you should be able to build your example with MinGW Distro and NetBeans 8. I recommend to not configure a absolute path to the make.exe file but add that path to your Microsoft Windows environment variable PATH. Otherwise you may get build errors.
Maybe these two blog posts help if you want to use the "default" MinGW distribution:
Installing Minimum GNU for Windows (MinGW)
Configure NetBeans IDE for Minimum GNU for Windows (MinGW)
I hope this helps others as well.
Not related to your question: Don't use using namespace std:
#include <iostream>
int main(int argc, char** argv) {
int n;
std::cin >> n;
std::cout << n;
return 0;
}
I ran into this same issue (with exit code -1,073,741,511), so though a dated question, I'm posting this here for anyone else who runs into the problem.
Run the executable for the program manually. You might get an error such as "the procedure entry point __gx_personality_v0 coud not be located in the dynamic library libstdc++-6.dll". (OP has confirmed this in a comment.)
The .dll file referred to in the error message above is either not being linked, or linked incorrectly. The correct version of the .dll that needs to be linked is the one in the ...\MinGW\bin directory. In Windows, you can check the .dll file being linked by typing where libstdc++-6.dll in a command prompt; the first result that is listed will be the file that is linked. If you already see ...\MinGW\bin\libstdc++-6.dll as the first result here, my fix below will not help you.
If you see a message "INFO: Could not find files for the given pattern(s).", then ...\MinGW\bin needs to be added to your %PATH% variable. (OP has already confirmed this was not the issue.)
The issue I was having was that a program I had installed had its own (likely outdated) version of libstdc++-6.dll, which was in a folder also included in my %PATH% variable, ahead of ...\MinGW\bin. This meant that this other .dll file was being picked up and linked to during execution. This can be fixed by editing your %PATH% variable to make sure the ...\MinGW\bin entry is ahead of all other directories that also have a version of the .dll file.
Edit: The other option is to statically link the .dll at program compilation, or place a copy of the correct .dll in the program executable directory. However, neither of these fixes is 'global', and needs to be done for each project individually.
Hope this helps!

Trying to set up the GNU C++ COMPILER, but I get an error I don't understand when I try to compile hello.cpp

So I bought this book called C++ Programming In Easy Steps by Mike McGrath online.
In the instructions it specifies to create a source file written in C++, the infamous "helo world". So I created my cpp file through sublime text editor and moved it to a file called MyPrograms in my C directory.
The code is as follows:
#include <iostream>
using std::cout;
using std::endl;
int main()
{
cout << "hello world"<< endl ;
return 0 ;
}
I have also tried:
#include
using namespace std;
int main()
{
cout << "hello world"<< endl ;
return 0 ;
}
Ok so I saved this file as hello.cpp in C:\MyPrograms.
Then here is where the error occurs....
I open cmd.
I do "c++"
I receive the message "c++: no input files".Which is what I'm supposed to recieve according to the book.
I proceed to do "cd\myprograms" to enter into the MyPrograms directory.
Once in that directory I do "c++ hello.cpp". According to the book this is supposed to compile my source file and create an executable file next to it. Instead I get a long error message that end in collect 2: 1d returned 1 exit status.
When I visit MyPrograms no executable file has been made next to the original cpp file.
I have also tried to do "c++ hello.cpp -o hello.exe" but it gives me the error again. All of this is done on the command prompt.
Please help :(
It looks to me like MinGW isn't installed properly.
First, it looks like you are trying to use version 4.0.3 but it may be conflicting with a version 3.4.5 that you installed previously (one in c:\mingw and the other in e:\p\giaw\src\pkg).
The latest version of MinGW is 4.7.2.1 which you can install from here: http://www.mingw.org/wiki/InstallationHOWTOforMinGW
But it looks like you're just starting out and it may be better to work with something that's better optimized for Windows (unless you're trying to compile Free Software). You can get a copy of Visual Studio Express for free here:
http://www.visualstudio.com/downloads/download-visual-studio-vs#d-express-windows-desktop
There are older versions available as well if you scroll down (VSE 2010).