I need to create C++ app using thrift and build it using SCons. In order to do so I've downloaded and installed all of the needed libs (and ensured that all of them are for x64 Windows) - boost, openssl, libevent.
I've built boost with command:
b2 -j4 toolset=msvc-14.1 address-model=64 architecture=x86 link=static threading=multi runtime-link=shared --build-type=complete stage --stagedir=stage/x64
Next, I've built Thrift libs in VS2017 (x64/Release).
But, when I try to build project with SCons, I encounter erros.
When I try with SConstruct file like this (run from Developer Command Prompt for VS2017):
import os
from os import path, listdir
gen_cpp = [path.join('gen-cpp', f) for f in listdir('gen-cpp') if
f.endswith('.cpp')]
client_source = [path.join('logic', folder, f) for folder in ['', 'parser',
'mars', 'view']
for f in listdir(path.join('logic', folder)) if
f.endswith('.cpp')]
server_source = [path.join('server', 'server.cpp')]
tests_source = [path.join('test_cases', f) for f in listdir('test_cases') if
f.endswith('.cpp')]
cpppath = ['.','c:\\Users\\Antek\\libs\\thrift-0.10.0\\thrift-
0.10.0\\lib\\cpp\\src\\','c:\\Users\\Antek\\libs\\boost_1_64_0\\boost\\']
libpath = ['C:\\Users\\Antek\\libs\\thrift-0.10.0\\thrift-
0.10.0\\lib\\cpp\\x64\\Release\\',
'c:\\Users\\Antek\\libs\\boost_1_64_0\\boost\\stage_x64\\lib\\',
'C:\\OpenSSL-Win64\\lib']
libs = ['libthrift']
env = Environment(
CPPPATH = cpppath,
LIBS = libs,
LIBPATH = libpath,
CPPFLAGS='/EHsc',
)
gen_cpp_o = env.Object(gen_cpp)
client_o = env.Object(client_source)
tests_o = env.Object(tests_source)
tests_files = gen_cpp_o + [f for f in client_o if str(f) !=
path.join('logic', 'main.obj')] + tests_o
env.Program('CoreWars', gen_cpp_o + client_o)
env.Program('Server', gen_cpp_o + server_source)
env.Program('tests', tests_files)
I get:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
cl /Fogen-cpp\MARS.obj /c gen-cpp\MARS.cpp /TP /nologo /EHsc /I.
/IC:\Users\Antek\libs\thrift-0.10.0\thrift-0.10.0\lib\cpp\src
/IC:\Users\Antek\libs\boost_1_64_0\boost
'cl' is not recognized as an internal or external command,
operable program or batch file.
scons: *** [gen-cpp\MARS.obj] Error 1
scons: building terminated because of errors.
When I add the following line to my SConstruct:
ENV = os.environ
I get an error :
Libthrift.lib (TOutput.obj): MSIL .netmodule module found or module compiled
with / GL; Consolidation will start again with the / LTCG option; Add the /
LTCG option to the consolidation command line to improve the performance of
the consolidator
Fatal error C1905: Frontend and backend are not compatible (must refer to
the same processor)
LINK: fatal error LNK1257: code generation failed
Scons: *** [CoreWars.exe] Error 1257
Scons: building terminated because of errors
I've spent too much time on this already, all ideas will be highly appreciated. Thank You.
Related
I have built libtorrent with boost with this commands in the boost root folder :
bootstrap.bat
b2 --hash cxxstd=14 release
and after I have added BOOST_ROOT and BOOST_BUILD_PATH to PATH variable.
I also have downloaded OpenSSL and build it then have copied to Visual studio 15 2017 compiler include and libs folder repectively.
Next in the libtorrent root folder I have run this commands:
b2 variant=release link=shared
b2 install --prefix=build
The build was successful and libtorrent c++ library has created.
and after that I have run these commands :
py setup.py build
py setup.py install
They executed with no errors and libtorrent installed in my python
libs/site-packages folder. But when I import it this error shows:
Python Import Error
[]
What build steps might I have done wrong?
Os : Windows 10 x64
Python : 3.9.5 x64
Libtorrent : 2.0.5
Boost : 1.78.0
I have followed from the libtorrent docs :
https://libtorrent.org/building.html
and
https://www.libtorrent.org/python_binding.html
What did I do ?
Basically following: https://github.com/arvidn/libtorrent/blob/master/docs/building.rst#downloading-and-building
Unzipping boost_1_78_0.zip into D:\boost_1_78_0, and running:
set BOOST_ROOT=D:\boost_1_78_0
set BOOST_BUILD_PATH=%BOOST_ROOT%\tools\build
(cd %BOOST_ROOT% && .\bootstrap.bat)
echo using msvc ; >>%HOMEDRIVE%%HOMEPATH%\user-config.jam
%BOOST_ROOT%\b2.exe --hash release
After this i got:
The Boost C++ Libraries were successfully built!
The following directory should be added to compiler include paths:
D:\boost_1_78_0
The following directory should be added to linker library paths:
D:\boost_1_78_0\stage\lib
I think this is where i started to fail, I did not read this the first time, and now I am asking meself where/how should the "compiler include paths" and "linker library paths" be set .?
When trying to compile libtorrent, using the command-line you provided (b2 msvc-14.2 variant=release link=static runtime-link=static debug-symbols=on), i got:
CXXFLAGS =
LDFLAGS =
OS = NT
building boost from source directory: D:/boost_1_78_0
Performing configuration checks
- default address-model : 64-bit (cached) [1]
- default architecture : x86 (cached) [1]
[1] msvc-14.2
...patience...
...patience...
...patience...
...found 3888 targets...
...updating 78 targets...
compile-c-c++ bin\msvc-14.2\release\cxxstd-14-iso\debug-symbols-on\link-static\runtime-link-static\threading-multi\src\hasher.obj
hasher.cpp
D:\TEMP\libtorrent\libtorrent\include\libtorrent/hasher.hpp(66): fatal error C1083: Cannot open include file: 'openssl/sha.h': No such file or directory
call "bin\standalone\msvc\msvc-14.2\msvc-setup.bat" >nul
cl /Zm800 -nologo "src\hasher.cpp" -c -Fo"bin\msvc-14.2\release\cxxstd-14-iso\debug-symbols-on\link-static\runtime-link-static\threading-multi\src\hasher.obj" -TP /bigobj /wd4251 /wd4268 /wd4275 /wd4373 /wd4503 /wd4675 /EHs /std:c++14 /GR /Zc:throwingNew /O2 /Z7 /Ob2 /W4 /MT /Zc:forScope /Zc:wchar_t /Zc:inline /Gw /favor:blend -DBOOST_ALL_NO_LIB -DBOOST_ASIO_ENABLE_CANCELIO -DBOOST_ASIO_HAS_STD_CHRONO -DBOOST_ASIO_NO_DEPRECATED -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION -DBOOST_NO_DEPRECATED -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_SYSTEM_STATIC_LINK=1 -DNDEBUG -DOPENSSL_NO_SSL2 -DTORRENT_BUILDING_LIBRARY -DTORRENT_SSL_PEERS -DTORRENT_USE_I2P=1 -DTORRENT_USE_LIBCRYPTO -DTORRENT_USE_OPENSSL -DWIN32 -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE -D_FILE_OFFSET_BITS=64 -D_SCL_SECURE_NO_DEPRECATE -D_WIN32 -D_WIN32_WINNT=0x0600 -D__USE_W32_SOCKETS "-ID:\boost_1_78_0" "-Ideps\try_signal" "-Iinclude" "-Iinclude\libtorrent"
...failed compile-c-c++ bin\msvc-14.2\release\cxxstd-14-iso\debug-symbols-on\link-static\runtime-link-static\threading-multi\src\hasher.obj...
compile-c-c++ bin\msvc-14.2\release\cxxstd-14-iso\debug-symbols-on\link-static\runtime-link-static\threading-multi\src\merkle.obj
merkle.cpp
D:\TEMP\libtorrent\libtorrent\include\libtorrent/hasher.hpp(66): fatal error C1083: Cannot open include file: 'openssl/sha.h': No such file or directory
..... (rest of logging removed)
I found the answer.
While building libtorrent python binding 2 factors are important:
1- openSSL version
2- linking type
python comes with openssl v.1.1 (or similar based on python version) , if building python binding with openssl v.1.1 (which is the latest version while I am writing) one dependency solved otherwise, if using openssl v.3 for building 2 dependency must add to python which they are:
// 32 or 64 bits library based on openssl build
libssl-3-x64.dll
libcrypto-3-x64.dll
2 ) in the time of building python binding 2 commands can be use:
a ) simple with default parameters :
py setup.py build
py setup.py install
In this case in default libtorrent and boost-python linking static.
b ) complex one with more control (I think) :
py setup.py build_ext --b2-args="VARS" install
In the VARS place we can write boost build options but these are the one we want:
libtorrent-link=TYPE boost-link= TYPE
TYPE can be static or shared but anyone that sets shared , it becomes dependency. two files which is in need are :
// 32 and 64 bits file may have different name
// files can have different names but they are similar to below
torrent-rastarbar.dll
boost_python(PYTHON-VERSION)(SOME-INFO).dll
boost python can be find in the boost root directory in the stage/lib .
pleae note that you must build boost and libtorrent SHARED for this solution.
Conclusion :
as mentioned above these dependency must add to based on the build setting you did:
1 - OpenSSL libraries
2 - Boost python
3 - libtorrent libraries
There is an optional file that mentioned in some forums and discussion msvcr90.dll which does not effect on my project but good to point.
Put those files to a directory which can be find by python interpreter or put in project your folder and add this piece of code before imporing libtorrent :
import os
current_path = os.path.abspath(".")
# do not pass relative path like ".", pass full path
os.add_dll_directory(current_path)
Sorry for any poor english. :)
Hey I'm trying to build TBB on my Windows computer using MinGW & CMake. (gcc,,g++, ..)
I have already tried using the premade binaries but I keep getting undefined reference issues.
My cmake for the project I'm trying to import it in looks as following:
find_package(TBB REQUIRED tbb)
target_link_libraries(projectName PRIVATE ${TBB_IMPORTED_TARGETS})
I use the source code of https://github.com/oneapi-src/oneTBB/releases/tag/v2021.3.0 (latest)
and I make a build dir and cd into it and execute:
cmake .. -G "MinGW Makefiles"
followed by:
cmake --build .
also tried:
mingw32-make
Both result into
[ 1%] Building CXX object src/tbb/CMakeFiles/tbb.dir/address_waiter.cpp.obj
In file included from c:\users\refactor\downloads\onetbb-2021.3.0\onetbb-2021.3.0\include\oneapi\tbb\detail\_utils.h:26,
from C:\Users\Refactor\Downloads\oneTBB-2021.3.0\oneTBB-2021.3.0\src\tbb\address_waiter.cpp:17:
c:\users\refactor\downloads\onetbb-2021.3.0\onetbb-2021.3.0\include\oneapi\tbb\detail\_machine.h:67: error: ignoring '#pragma intrinsic ' [-Werror=unknown-pragmas]
67 | #pragma intrinsic(_mm_mfence)
|
compilation terminated due to -Wfatal-errors.
cc1plus.exe: all warnings being treated as errors
mingw32-make[2]: *** [src\tbb\CMakeFiles\tbb.dir\build.make:76: src/tbb/CMakeFiles/tbb.dir/address_waiter.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:454: src/tbb/CMakeFiles/tbb.dir/all] Error 2
mingw32-make: *** [makefile:165: all] Error 2```
As mentioned in the comments there are issues building with MinGW with the latest versions of TBB.
The last version of TBB I was able to build was 2020.0 using this command (replace intel64 with ia32 for 32-bit):
mingw32-make compiler=gcc arch=intel64 runtime=mingw tbb tbbmalloc CPLUS="g++ -static-libstdc++ -static-libgcc"
I'm attempting to build firmware from a GitHub project, which uses GCC-ARM, SCons, and OpenOCD (I'm using a Mac btw). If I run "scons" from the command line, the project builds just fine.
However, I want to use Eclipse to build the project. I installed "SConsolidator" and "GNU ARM on Eclipse" plugins, and I imported the project as a Scons project. I also went into project Properties -> C/C++ General -> Paths and Symbols and I added the GNU ARM includes directory for GNU C and GNU C++ under the includes tab.
However, when I try to build the project, I get this:
=== Running SCons at 10/5/16 10:04 PM ====
Command line: /usr/local/bin/scons -u --jobs=8
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: building associated VariantDir targets: build/lpc11c14 build/lpc1549 build
CXX build/BMS/src/ADT7470Fan.o
sh: arm-none-eabi-g++: command not found
CXX build/BMS/src/main.o
sh: arm-none-eabi-g++: command not found
CXX build/BMS/src/peripherals.o
sh: arm-none-eabi-g++: command not found
CXX build/BMS/src/pins.o
sh: arm-none-eabi-g++: command not found
CXX build/Cutoff/src/main.o
sh: arm-none-eabi-g++: command not found
CXX build/Cutoff/src/peripherals.o
sh: arm-none-eabi-g++: command not found
CXX build/Cutoff/src/pins.o
sh: arm-none-eabi-g++: command not found
scons: *** [build/BMS/src/ADT7470Fan.o] Error 127
CXX build/Dashboard/src/can_dash.o
scons: *** [build/BMS/src/main.o] Error 127
scons: *** [build/BMS/src/peripherals.o] Error 127
scons: *** [build/BMS/src/pins.o] Error 127
scons: *** [build/Cutoff/src/main.o] Error 127
scons: *** [build/Cutoff/src/peripherals.o] Error 127
scons: *** [build/Cutoff/src/pins.o] Error 127
sh: arm-none-eabi-g++: command not found
scons: *** [build/Dashboard/src/can_dash.o] Error 127
scons: building terminated because of errors.
Duration 9132 ms.
I'm following the instructions on the Github's page, and it works for other people, so I'm not sure what I'm doing wrong. I suspect it has to do with the $PATH not registering for Eclipse, since I added /usr/local/gcc-arm-none-eabi-5_4-2016q3/bin to the $PATH using ~/.bash_profile so "scons" would work in command line.
You may need to enable running 32 bit binaries on your 64 bit userland.
For debian:
dpkg --add-architecture i386
sudo apt-get install libstdc++6:i386
Trying to get a test case working so that I can compile C++ using scons.
However I am getting this error:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: warning: No version of Visual Studio compiler found - C/C++ compilers most likely not set correctly
File "C:\Python27\Scripts\scons.py", line 199, in <module>
C:/Qt/Tools/mingw492_32/bin/g++.exe -o test.o -c test.cpp
scons: *** [test.o] Error 1
scons: building terminated because of errors.
Here is my SConstruct at this time:
env = Environment(tools = ["mingw"], TARGET_ARCH=['x86'])
env.Replace(CXX = 'C:/Qt/Tools/mingw492_32/bin/g++.exe')
env.Program("main","test.cpp")
I am confused by the visual studio error, because I have specified that I want to use mingw.
My problem in this case was caused by me using PowerShell for the first time. Which for some reason that I have not yet learned, does not provide popups of error messages. When I used cmd I saw that I had a path issue, and scons was otherwise working fine.
I need to build a Qt5 64 bit program which links to static .lib libraries (compiled with /MT). I tried changing the lines below from MD to MT:
QMAKE_CFLAGS_RELEASE = -O2 -MT
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += -O2 -MT -Zi
QMAKE_CFLAGS_DEBUG = -Zi –MTd
in the file D:\Qt\Qt5.0.0src\qtbase\mkspecs\win32-msvc2010\qmake.conf
and recompiling it with
configure -prefix %CD%\qtbase -debug-and-release -opensource -platform win32-msvc2010 -opengl desktop
and then nmaking it, but it failed with:
XPathGrammar.cpp
Generating Code...
lib /NOLOGO /OUT:release\WebCore.lib #C:\Users\Paul\AppData\Local\Temp\WebCore.lib.4480.3319717.jom
LINK : fatal error LNK1181: cannot open input file '.obj\release_shared\SettingsMacros.obj'
jom: D:\Qt\Qt5.0.0src\qtwebkit\Source\WebCore\Makefile.WebCore.Target.Release [release\WebCore.lib] Error 1181
jom: D:\Qt\Qt5.0.0src\qtwebkit\Source\WebCore\Makefile.WebCore.Target [release] Error 2
jom: D:\Qt\Qt5.0.0src\qtwebkit\Source\WebCore\Makefile.WebCore [sub-Target-pri-make_first-ordered] Error 2
jom: D:\Qt\Qt5.0.0src\qtwebkit\Makefile [sub-Source-WebCore-WebCore-pro-make_first-ordered] Error 2
jom: D:\Qt\Qt5.0.0src\Makefile [module-qtwebkit-make_first] Error 2
It seems that the "SettingsMacros.obj" file doesn't get generated. Why is that?
Do I need to include "-static" in the configure string? I know that Qt doesn't get along with /MT but my project needs it otherwise I would not be able to link those .lib files
yes, you do need to add -static. Worked for me.