I tried to compile and run a new small program via windows cmd (I usually use an IDE so I am not experienced at using a terminal).
I have 2 source files, my main.cpp and a function.cpp as well as the header of the latter, function.h.
In cmd I type:
g++ -c main.cpp
g++ -c function.cpp
g++ -o main main.o function.o
This creates an exe file but if I try to run it I get the error message that "the procedure entry point [string of cryptic symbols] could not be found in the dynamic link library".
#include "arithmetic_med_from_file.h"
#include <iostream>
#include <string>
usingnamespace std;
int main(){
string filename;
size_t N;
double result;
cout<<"Type in the name of the file!"<<endl;
cin>>filename;
cout<<"Type in the index N of the row in the file from which you want to start calculating the arithmetic medians (N must not be smaller than number of rows in file)!"<<endl;
cin>>N;
result=arithmetic_med_from_file(N, filename);
cout<< "arithmetic median of the y-values of the last N rows of file '" + filename + "' is :" <<endl;
cout<< result;
return 0;
}
Post the exact "string of cryptic symbols". Also, after "could not be found in the dynamic link library" there should be the name of a DLL. What is it?
"The procedure entry point _ZNKSt7__cxx1112basic_stringlcSt11char_traitslcESalcEE4sizeEv could not be located in the dynamic link library [ABSOLUTE PATH OF calculate_median.exe]"
There is nothing even remotely similar to hard spheres in the main() that you have posted.
There definitely is no line 21: constdouble V_0 {N*PI*(4./3)*R*R*R}; in your main.cpp.
Have you edited your code, or are you compiling entirely different files?
Sorry guys, I typed in "function.cpp" and "main.cpp" even though they are only the names I gave them here in this thread above my portrayed code. Ironically, in the same folder I have a "true" main file that was accessed instead.
However, using the real names and typing g++ -std=gnu++17 -Wall -Wextra -pedantic-errors arithmetic_med_from_file.cpp calculate_median.cpp -o calculate_median.exe
...gives a similar error message as the one from the beginning. It creates an exe, but when I try to run it:
"The procedure entry point _ZNKSt9basic_ioslcSt11char_traitslcEEcvbEv could not be located in the dynamic link library [absolute path to .exe]"
I’ve created a new folder and copied&pasted your code into the files
- arithmetic_med_from_file.cpp
- arithmetic_med_from_file.h
- calculate_median.cpp
Then, I opened a cmd window and typed: g++ -std=gnu++17 -Wall -Wextra -pedantic-errors arithmetic_med_from_file.cpp calculate_median.cpp -o calculate_median.exe
Again, it compiled 0 errors 0 warnings.
Shall we try to isolate the problem? Could you please try creating a new folder and putting inside these files:
a.h:
1 2 3 4 5 6
#ifndef A_H
#define A_H
int myfunc();
#endif // A_H
I’ve created a new folder and copied&pasted your code into the files
- arithmetic_med_from_file.cpp
- arithmetic_med_from_file.h
- calculate_median.cpp
Then, I opened a cmd window and typed:
g++ -std=gnu++17 -Wall -Wextra -pedantic-errors arithmetic_med_from_file.cpp calculate_median.cpp -o calculate_median.exe
Again, it compiled 0 errors 0 warnings.
But does the .exe run? I don't get errors through compiling either, the error comes if I try to run the function. I tried it with a new folder as well, same problem.
I am going to try your suggestion now.
edit: I did the stuff with a.cpp and main.cpp. It worked and I don't get an error, neither in compilation nor in execution.
#include "a.h"
#include <iostream>
#include <string>
usingnamespace std;
int main(){
string filename;
size_t N;
double result;
cout<<"Type in the name of the file!"<<endl;
cin>>filename;
cout<<"Type in the index N of the row in the file from which you want to start calculating the arithmetic medians (N must not be smaller than number of rows in file)!"<<endl;
cin>>N;
result=arithmetic_med_from_file(N, filename);
cout<< "arithmetic median of the y-values of the last N rows of file '" + filename + "' is :" <<endl;
cout<< result;
return 0;
}
Compiling using g++ a.cpp main.cpp -o main.exe works fine, but the .exe file still gives that strange error. That should imply that there is a problem in the code somehow, right?
Ok, but I don't really understand what I am supposed to do.
The whole error looks a bit weird, but I guess your issue is caused by multiple conflicting DLLs in your PATH. You should be able to test this hypothesis by going into c:\mingw\bin, clearing PATH completely (set PATH= in the Windows shell; export PATH= in Bash) and trying to execute as --help again. If that helped, you need to identify what program in your PATH is causing this and either remove it from PATH completely, or remember to set a custom, short, non-conflicting PATH everytime you want to use your mingw installation.
So I should delete my whole PATH? And what does "export in Bash" mean?