Im learning to use intrinsics instead of asm-inlining. Yesterday, they were working but I always get error today. Changed nothing.
#include <iostream>
#include <intrin.h> // immintrin.h, smmintrin.h ... tried all, never worked
using namespace std;
int main()
{
_m256_zeroupper(); // __mm256_zeroupper(); does not work too
_mm128 x; // __mm128 x; does not work too
_mm256 y; // __mm256 y; does not work too
_m256_zeroupper(); // __mm256_zeroupper(); does not work too
cout << "Hello world!" << endl;
return 0;
}
Here are the errors. I tried all header files for different intrinsics but errors were same. Also reinstalled gcc but did not work.
Where am I wrong? What do I need to add to actually declare these intrinsic variables and functions?
C:\indirmeDenemesi\hello_intrin\main.cpp||In function 'int main()':|
C:\indirmeDenemesi\hello_intrin\main.cpp|8|error: '_mm256_zeroupper' was not declared in this scope|
C:\indirmeDenemesi\hello_intrin\main.cpp|9|error: '_mm128' was not declared in this scope|
C:\indirmeDenemesi\hello_intrin\main.cpp|9|error: expected ';' before 'x'|
C:\indirmeDenemesi\hello_intrin\main.cpp|10|error: '_mm256' was not declared in this scope|
C:\indirmeDenemesi\hello_intrin\main.cpp|10|error: expected ';' before 'y'|
||=== Build finished: 5 errors, 0 warnings (0 minutes, 0 seconds) ===|
Using 64-bit latest version of gcc on 64bit cpu with 64 bit windows.
CPU is FX8150.
Tried -march=bdver1 -mtune=bdver1 and it produced hundreds of junk error.
Does all these mean my CPU is dying?
Edit: some other projects are working now, but I did not change anything. This must be a project-specific thing.
Using code::blocks and when I right-click on a header and select "open", it gives error "could not find" but does not give any error when compiling related to that, just error for intrinsinc commands. Same for working projects(they compile everything and work, but does not find header files when right click and click open). Maybe some other windows services were interfering? I dont know but compiler errors are vanishing and coming again, time to time. Reinstalling also codeblocks did not solve. Only some projects can use intrinsics while other projects cannot(even if all projects have same headers.)
This code below does not work too.
#include <iostream>
#include <immintrin.h>
using namespace std;
int main()
{
_m256_zeroupper();
__mm128 x;
__mm256 y;
_m256_zeroupper();
cout << "Hello world!" << endl;
return 0;
}
Three things should make your code work:
Make sure you're using the -mavx compile flag.
Your variable should be declared as __m256 not _mm256.
Make sure you're including immintrin.h
When trying to build a simple helloworld program, the next error shows up
LINK : fatal error LNK1561: entry point must be defined
I'm trying to use the systemc library in Visual Studio 2015, maybe thats the problem because, I couldn't find any help configuring this VS for systemc only for VS2010. The program is the following:
// All systemc modules should include systemc.h header file
#include "systemc.h"
// Hello_world is module name
SC_MODULE (hello_world) {
SC_CTOR (hello_world) {
// Nothing in constructor
}
void say_hello() {
//Print "Hello World" to the console.
cout << "Hello World.\n";
}
};
// sc_main in top level function like in C++ main
int sc_main(int argc, char* argv[]) {
hello_world hello("HELLO");
// Print the hello world
hello.say_hello();
return(0);
}
The curious thing is that if I exchange the sc_main for main it builds but doesn't work.
Your code is fine so you have a build issue. Check that you are pointing to the correct SystemC include and systemc.lib file.
There are issues with building current SystemC 2.3.1 in Visual Studio 2015. http://forums.accellera.org/topic/5026-microsoft-visual-studio-community-2015/
VS2013 works fine.
I wrote this C code
#include <stdio.h>
int main()
{
int a;
scanf("%d", &a);
printf("%d\n", a);
getchar();
return 10;
}
However I am getting this error shown in image.
What is the problem here ?
EDIT1:
I have windows 7 x64 and running VS 15.
Seems there has been similar problem before this might be helpfull.
Visual Studio debugger error: Unable to start program Specified file cannot be found
Go to the specific file location from the error open the program from there. Build it first then try to debug it again.
I am an amateur VC++ developer.
I want to use CoolProp (http://www.coolprop.org/) in my academic VC++ project as a static library in a win 32 app using a VS2010 Ultimate running in x64 laptop machine.
So i have downloaded ,
1.CoolProp.lib from http://sourceforge.net/projects/coolprop/files/CoolProp/5.0.2/static_library/
2.CoolProp.h from http://sourceforge.net/projects/coolprop/files/CoolProp/5.0.0/shared_library/
and placed both in a system folder.
Next i created a sample win32 console application in VS2010 as empty sln.
Added CoolProp.h as an Additional Include Directories in Properties->C/C++->General(Also copied all the dependent header files)
Added CoolProp.lib as an Additional Dependencies in Properties->Linker->Input->Additional Dependencies
Then i copied this program from http://www.coolprop.org/coolprop/HighLevelAPI.html#high-level-api
#include "CoolProp.h"
#include <iostream>
using namespace CoolProp;
int main()
{
// First type (slowest, due to most string processing, exposed in DLL)
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"Propane[0.5]&Ethane[0.5]") << std::endl; // Default backend is HEOS
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"HEOS::Propane[0.5]&Ethane[0.5]") << std::endl;
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"REFPROP::Propane[0.5]&Ethane[0.5]") << std::endl;
std::vector<double> z(2,0.5);
// Second type (C++ only, a bit faster)
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"Propane&Ethane", z) << std::endl;
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"HEOS::Propane&Ethane", z) << std::endl;
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"REFPROP::Propane&Ethane", z) << std::endl;
return EXIT_SUCCESS;
}
and tried to build.
Build(but compiled perfectly) failed due to
main.obj : error LNK2019: unresolved external symbol "double __cdecl PropsSI(char,char,double,char,double,char *)" (?Props##YANDDNDNPAD#Z) referenced in function _main
Can somebody please help me in resolving this ?
I already read below posts from stackoverflow , but couldnt solve please help
What is an undefined reference/unresolved external symbol error and how do I fix it?
"error LNK2019: unresolved external symbol" error in Visual Studio 2010
Error LNK2019: Unresolved External Symbol in Visual Studio
It is working for me, (VS 2010) as following:
-add file 'CoolPropLib.h' to your project, by right click on header files folder in solution explorer -> Add -> Existing Item -> choose 'CoolPropLib.h'.
-open file 'CoolPropLib.h' and comment line 22 as follow (//#include "PlatformDetermination.h").
- add these two lines (23, 24) :
#define CONVENTION __stdcall
#define EXTERNC
-use library that is built with __stcall not that built with __cdecel : http://sourceforge.net/projects/coolprop/files/CoolProp/5.0.0/shared_library/Windows/32bit__stdcall_calling_convention/CoolProp.lib/download
-you will need the dll (for __stdcall) from : http://sourceforge.net/projects/coolprop/files/CoolProp/5.0.0/shared_library/Windows/32bit__stdcall_calling_convention/CoolProp.dll/download
-create folder named 'lib' in your project folder in windows explorer (not in VS) and put 'CoolProp.lib' in it.
-in Properties->Linker->General-> Additional libraries Directories, add $(ProjectDir)\lib
-the code I test is:
#include "stdafx.h"
#include <iostream>
#include <vector>
#include "CoolPropLib.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
// First type (slowest, due to most string processing, exposed in DLL)
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"Propane[0.5]&Ethane[0.5]") << std::endl; // Default backend is HEOS
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"HEOS::Propane[0.5]&Ethane[0.5]") << std::endl;
std::cout << PropsSI("Dmolar","T",298,"P",1e5,"REFPROP::Propane[0.5]&Ethane[0.5]") << std::endl;
return 0;
}
-if you have problems, I can upload the project to you.
EDIT 1:
I mean 'CoolPropLib.h' not 'CoolProp.h', I correct it; In your question, you named it as 'CoolProp.h'.
As you mentioned in your comment; you can change calling convention as _stdcall in Properties->c/c++ ->Advanced .
I am one of the the primary developers for CoolProp. Thank you #houssam for your helpful reply. The problem with going the DLL (shared library) route is that you lose access to a lot of useful low-level functions, whereas if you link with the static library, you still have access to all the low-level code
The better plan is to build the static library yourself, as it is required that the compiler that is used to build the static library is EXACTLY the same as the compiler used to compile your project. In order to do that, you can follow the directions here: http://www.coolprop.dreamhosters.com:8010/sphinx/coolprop/wrappers/StaticLibrary/index.html#static-library , basically you need to do
# Check out the sources for CoolProp
git clone https://github.com/CoolProp/CoolProp --recursive
# Move into the folder you just created
cd CoolProp
# Make a build folder
mkdir build && cd build
# Build the makefile using CMake
cmake .. -DCOOLPROP_STATIC_LIBRARY=ON -G "Visual Studio 10 2010"
# Make the static library
cmake --build .
You then need to link the static library as described by #houssam. No other changes should be required to your code.
In the future, the coolprop-users#googlegroups.com mailing list or https://github.com/CoolProp/CoolProp/issues are good places to ask questions.
When I try to execute my qt program on another computer, I receive this error and crash:
Failed to load platform plugin "windows". Available platforms are:
windows
I know that this problem has been discussed in several other questions:
failed to load platform plugin "windows" Available platforms are: windows, minimal
Qt application: Failed to load platform plugin "windows". Available platforms are:
PyQt5 - Failed to load platform plugin "windows". Available platforms are: windows, minimal
But I have applied the suggested solutions, and it still doesn't work for me. Relevant information:
I use Qt 5.1.0 with MinGW 4.8 32bit for development
on my development pc (Win7, 64bit) the program executes just fine
I compiled my application in release mode
the target pc (Win7, 32bit) does not have Qt installed
part of my .pro:
QT += core gui opengl network xml testlib
TARGET = myApp
TEMPLATE = app
CONFIG += qtestlib help
CONFIG -= app_bundle
content of my deployment folder:
myApp.exe
[all dlls, that are in the .exe folder of my development environment]
[all dlls from Qt/5.1.0/5.1.0/mingw48_32/bin]
[all dlls from Qt/5.1.0/Tools/mingw48_32/bin] (including libEGL.dll, libEGLd.dll, libGLESv2.dll, libGLESv2d.dll)
[all dlls from Qt/5.1.0/Tools/QtCreator/bin]
platforms/qwindows.dll
I had same issue with qwindows.dll -- win7 64 ok, win7 32 fail with unable to find qwindows.dll
first of all i checked i can run it with -platformpluginpath:
app.exe -platformpluginpath plugins/platforms
everything ok, so the problem is just wrong search pathes inside app.
I ended with just adding all possible pathes:
#include <QApplication>
#include <QDir>
void registerPluginsDir(QDir& exeDir)
{
#ifdef Q_OS_MAC
QString pluginsRelPath = "/../../PlugIns";
#elif defined(Q_OS_WIN)
QString pluginsRelPath = "Plugins";
#elif defined (Q_OS_LINUX)
QString pluginsRelPath = "../lib/plugins";
#else
#error "Unsupported OS"
#endif
QString platformsRelPath = "platforms";
QString pluginsPath = exeDir.absoluteFilePath(pluginsRelPath);
QString platformsPath = QDir(pluginsPath).absoluteFilePath(platformsRelPath);
QStringList pathes = QCoreApplication::libraryPaths();
pathes << pluginsPath;
pathes << platformsPath;
pathes << platformsRelPath;
pathes << pluginsRelPath;
QCoreApplication::setLibraryPaths(pathes);
}
int main(int argc, char *argv[])
{
QString exePath = QString::fromUtf8(argv[0]);
QFileInfo exeInfo (exePath);
QDir exeDir (exeInfo.absolutePath());
//need to set correct plugins path before app instance created
registerPluginsDir(exeDir);
QApplication app(argc, argv);
// more code here
return app.exec();
}