Closed c4n10 closed 6 years ago
Hi,
I actually had similar issues (linker failures) on one of my PCs when compiling with MinGW 64-bit but on my other PC it worked file. So today I completely uninstalled MinGW 64-bit from my PC where compilation failed and then reinstalled it using the instructions below:
1) Download MSYS2 installer from http://www.msys2.org/
2) After MSYS2 installation open "MSYS2 MinGW 64-bit" and update using pacman -Syu
. Run update step twice to be sure everything has been updated.
3) Install MinGW 64-bit using pacman -S --needed base-devel unzip mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake
4) Now you should be able to compile primesieve using:
wget https://github.com/kimwalisch/primesieve/archive/master.zip
unzip master.zip
cd primesieve-master
mkdir build
cd build
cmake .. -G "Unix Makefiles"
make -j8
Please let me know if this works for you.
I can confirm, this solution DID work for me, thank you.
Hello,
I am trying to compile on MinGW and the basic build instructions are not working.
If I run: cmake . make -j from the root directory it gives this error: make: *** No targets specified and no makefile found. Stop.
I was able to work around that by: cd cmake cmake .. -G"Unix Makefiles"
However now when I run make -j I am receiving these errors: $ make -j Scanning dependencies of target libprimesieve-static [ 4%] Building CXX object CMakeFiles/libprimesieve-static.dir/src/api-c.cpp.obj [ 9%] Building CXX object CMakeFiles/libprimesieve-static.dir/src/api.cpp.obj [ 13%] Building CXX object CMakeFiles/libprimesieve-static.dir/src/CpuInfo.cpp.obj [ 18%] Building CXX object CMakeFiles/libprimesieve-static.dir/src/EratBig.cpp.obj [ 22%] Building CXX object CMakeFiles/libprimesieve-static.dir/src/EratMedium.cpp.obj [ 27%] Building CXX object CMakeFiles/libprimesieve-static.dir/src/EratSmall.cpp.obj [ 31%] Building CXX object CMakeFiles/libprimesieve-static.dir/src/iterator-c.cpp.obj [ 36%] Building CXX object CMakeFiles/libprimesieve-static.dir/src/nthPrime.cpp.obj [ 40%] Building CXX object CMakeFiles/libprimesieve-static.dir/src/iterator.cpp.obj[ 45%] Building CXX object CMakeFiles/libprimesieve-static.dir/src/ParallelPrimeSieve.cpp.obj [ 50%] Building CXX object CMakeFiles/libprimesieve-static.dir/src/popcount.cpp.obj [ 54%] [ 59%] [ 68%] [ 68%] Building CXX object CMakeFiles/libprimesieve-static.dir/src/PrimeSieve.cpp.obj Building CXX object CMakeFiles/libprimesieve-static.dir/src/PreSieve.cpp.obj[ 72%] Building CXX object CMakeFiles/libprimesieve-static.dir/src/PrimeGenerator.cpp.obj
[ 77%] Building CXX object CMakeFiles/libprimesieve-static.dir/src/SieveOfEratosthenes.cpp.objBuilding CXX object CMakeFiles/libprimesieve-static.dir/src/Wheel.cpp.objBuilding CXX object CMakeFiles/libprimesieve-static.dir/src/SievingPrimes.cpp.obj
C:/InIMi nnfG IifnlWi e/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp: In member function 'void primesieve::CpuInfo::initCache()': C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:189:36: warning: 'stdcall' attribute only applies to function types [-Wattributes] lf typedef BOOL (WINAPI LPFNGLPI)(PSYSTEM LOGICAL_PROCESSOR_INFORMATION, PDWORD); ^ info(size);
^ info(size);
^
C:/MicnGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:204:46: note: expected a type, got 'SYSTEM_LOGICAL_PROCESSOR_IiuNFORMATION'
C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:204:46: error: template argument 2 is invalid
C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:206:20: error: invalid types 'int[int]' for array subscript
l if (!glpi(&info[0], &bytes))
nd ^
C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:211:15: error: invalid types 'int[size_t {aka unsigned int}]' for array subscript
if (info[i].Relationship == RelationProcessorCore)
^
Cu:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:211:33: error: 'RelationProcessorCore' was not declared in this scope
if (info[i].Relationship == RelationProcessorCore)
^
~~~~~~~~ C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:189:36: error: typedef 'LPFN_GLPI' is initialized (use decltype instead) eiC:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:189:36: error: 'PSYSTEM_LOGICAL_PROCESSOR_INFORMATION' was not declared in this scope C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:189:81: error: expected primary-expression befiore ')' token typedef BOOL (WINAPI LPFN_GLPI)(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD); ^ C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:191:3: error: 'LPFN_GLPI' was not declared in this scope l LPFN_GLPI glpi = (LPFN_GLPI) GetProcAddress(GetModuleHandle(TEXT("kernel32")), "GetLogicalProcessorInformation"); ^~~~~ C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:193:8: error: 'glpi' was not declared in this scope if (!glpi) ^~~~ C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfon.cpp:197:17: error: 'glpi' was not declared in this scope glpi(0, &bytes); ^ C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:203:32: error: 'SYSTEM_LOGICAL_PROCESSOR_INFORMATION' was not declared in this scope size_t size = bytes / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION); ^~~~~~ie~~ C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:204:10: error: the value of 'SYSTEM_LOGICAL_PROCESSOR_INFORMATIONc' is not usable in a constant expression vector~~~~~~~C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:203:32: note: 'SYSTEM_LOGICAL_PROCESSOR_INFORMATION' was not declared 'constexpr' size_t size = bytes / sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION); ^~~~~~~~n C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:204:46: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector' l vector~~~~ceC:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpdp:213:25: error: invalid types 'int[size_t {aka unsigned int}]' for array subscript auto mask = info[i].ProcessorMask; ^ C:/MinGW/msys/1.0/home/c4n10/primesieve/srlc/CpuInfo.cpp:222:15: error: invalid types 'int[size_t {aka unsigned int}]' for array subscript if (info[i].Reldaeu tionsddfhip == RelationCache && ^ C:/MinGW/msys/1.0/home/c4n10/primesieve/src er/CpuInfo.cpp:222:33: error: 'RelationCache'fdo was not declared in this scope if (info[i].Relationship == RelationCache && ^~~~~ C:/MinGW/msys/1.0/home/c4n10/primesiever m/src/CpuInfo.cpp:223:16: error: invalid types 'int[size_t {aka unsigned int}]' for array subscript (info[i].Cache.Type == CacheData || ^ C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:223:32: error: 'CacheData' was not declared in this scope of (info[i].Cache.Type == CacheData || ^~~~~ mrCC:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:224:16: error: invalid types 'int[size_t {aka unsigned int}]' for array subscript info[i].Cache. o:Type == CacheUnified)) ^ C:/MinGW/msys/1.0/home/c4n10/primeCm/sieve/s: Mrc/CpuInfo.cCip/p:224:32: error: 'CacheUnified' was not declared in this scope info[i].Cache.Ty:nM/GiMWni/GnmWGs/Wym/ssm/ys1sy./s01//.1h0.o/0mh/eoh/mocem4/enc/14c0n4/1np01r/0ip/mrpeirsmiiemeseviseei/vesevr/ecs//rsacrp/cia/.pPciap-rpca:.l1cl7pe:ppe == CacheUnified)) ^~~~ C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:226:17: error: invalid types 'int[size_t {aka unsigned int}]' for array subscript if (info[i].Cache.Level == 1) ^ C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.c0l:pp:227:30: error: invalid types 'int[sizet {aka unsigned int}]' f:P1or array subscript l1CacheSize = info[i].Cache.Size; ^ C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:228:17: error: invalid types 'int[size_t {aka unsigned int}]' for r6 array subscript if (info[i].Cache.Level == 2) ^ C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:229:30: error: invalid types 'int[sizet {aka unsigned int}]' for array subscript l2CacheSize = info[i].Cache.Size; ^ C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:233:17: error: invalid types 'int[size_t {aka unsigned int}]' for array subscript if (info[i].Cache.Level == 3 && ^ C:/MinGW/msys/1.0/home/c4n10/primesieve/src/CpuInfo.cpp:234:17: error: invalid types 'int[sizet {aka unsigned int}]' for array subscript info[i].Cache.Size > 0) ^ i:Cm0:e:/S ieCnmake[2]: v:G [CMakeFiles/libprimesieve-static.dir/src/CpuInfo.cpp.obj] Error 1e/W.M/ spmake[2]: Gy:W Waiting for unfinished jobs.... /2m1:s.0y0:s/ 1oC.m:0e///Mhcio4nmnGe1W/0/c/m4psnry1is0m//e1ps.ri0ie/mvheeos/miieen/vccel4/unid1ne0c//lppurrdiiemm/eepssriiieemvveees//iPieanvrceal/luPldaeerl/aPplrrliiemmleePSsriiieemvveeeS./ihPepavpre:a.4lh7lp:ep8l::P4 r7ei:rm8re:oS rie:er vr'eom.ruh:tp ep'x:m'4u 7ti:en8x :'n aeimrner sonpraa:mc ee's mp'uastcteedx ''' sditonde 'sn adnmooeetss p nanacomete 'nasa tmtdey' p aed ey sp e n tt d :n :asmmtuedt :ea:x m tulytopecexk l; o k s t; d : m u t ^e ~x ~ ~l ~o^ k~_~;~make[2]: [CMakeFiles/libprimesieve-static.dir/src/api.cpp.obj] Error 1 make[2]: [CMakeFiles/libprimesieve-static.dir/src/api-c.cpp.obj] Error 1 C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp: In static member function 'static int primesieve::ParallelPrimeSieve::getMaxThreads()': C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp:59:22: error: 'thread' has not been declared return max(1, thread::hardware_concurrency());
^ >'
futures.emplaceback(async(launch::async, task));
^
In file included from C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp:21:0:
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\future:115:11: note: declaration of 'class std::future<std::vector >'
class future;
^ >'
counts += f.get();
^
In file included from C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp:21:0:
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\future:115:11: note: declaration of 'class std::future<std::vector >'
class future;
^ lock(lock , defer_lock);
^~~~~
C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp:194:20: error: template argument 1 is invalid
uniquelock lock(lock , deferlock);
^
C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp:194:27: error: 'lock' was not declared in this scope
uniquelock lock(lock , defer_lock);
^~~~~
C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp:194:44: error: expression list treated as compound expression in initializer [-fpermissive]
uniquelock lock(lock , defer_lock);
^
C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp:197:10: error: request for member 'try_lock' in 'lock', which is of non-class type 'int'
lock.try_lock();
^ >; _Alloc = std::allocator<std::future<std::vector > >; std::vector<_Tp, _Alloc>::size_type = unsigned int]':
C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp:166:28: required from here
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\vector.tcc:80:4: error: invalid use of incomplete type 'class std::future<std::vector >'
this->_M_impl._M_end_of_storage
~C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp: In member function 'virtual void primesieve::ParallelPrimeSieve::sieve()': C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp:169:53: error: invalid use of incomplete type 'class std::future<std::vector~C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp:172:19: error: invalid use of incomplete type 'class std::future<std::vector~C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp: In member function 'virtual bool primesieve::ParallelPrimeSieve::updateStatus(uint64_t, bool)': C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp:194:15: error: 'mutex' was not declared in this scope uniquelock~~~ C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp:199:10: error: request for member 'lock' in 'lock', which is of non-class type 'int' lock.lock(); ^~~~ C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp:201:12: error: request for member 'owns_lock' in 'lock', which is of non-class type 'int' if (lock.owns_lock()) ^~~~~ In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\vector:69:0, from C:/MinGW/msys/1.0/home/c4n10/primesieve/include/primesieve/PrimeSieve.hpp:17, from C:/MinGW/msys/1.0/home/c4n10/primesieve/include/primesieve/ParallelPrimeSieve.hpp:15, from C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp:12: c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\vector.tcc: In instantiation of 'void std::vector<_Tp, _Alloc>::reserve(std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::future<std::vectorIn file included from C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp:21:0: c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\future:115:11: note: declaration of 'class std::future<std::vector >'
class future;
^ >; _Alloc = std::allocator<std::future<std::vector > >; std::vector<_Tp, _Alloc>::size_type = unsigned int]':
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\vector.tcc:70:28: required from 'void std::vector<_Tp, _Alloc>::reserve(std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::future<std::vector >; _Alloc = std::allocator<std::future<std::vector > >; std::vector<_Tp, _Alloc>::size_type = unsigned int]'
C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp:166:28: required from here
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h:737:5: error: invalid use of incomplete type 'class std::future<std::vector >'
{ return size_type(this->_M_impl._M_end_of_storage
~In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\vector:64:0, from C:/MinGW/msys/1.0/home/c4n10/primesieve/include/primesieve/PrimeSieve.hpp:17, from C:/MinGW/msys/1.0/home/c4n10/primesieve/include/primesieve/ParallelPrimeSieve.hpp:15, from C:/MinGW/msys/1.0/home/c4n10/primesieve/src/ParallelPrimeSieve.cpp:12: c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\stl_vector.h: In instantiation of 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::capacity() const [with _Tp = std::future<std::vectordestroy(first, __last);