for static link boost library

This commit is contained in:
fasiondog 2019-10-19 22:25:06 +08:00
parent 5900654ed1
commit d733db32f8
9 changed files with 62 additions and 42 deletions

View File

@ -10,8 +10,11 @@
#include "../Stock.h" #include "../Stock.h"
#include "../Log.h" #include "../Log.h"
namespace hku { #if HKU_SUPPORT_SERIALIZATION
BOOST_CLASS_EXPORT(hku::IndicatorImp)
#endif
namespace hku {
HKU_API std::ostream & operator<<(std::ostream& os, const IndicatorImp& imp) { HKU_API std::ostream & operator<<(std::ostream& os, const IndicatorImp& imp) {
os << "Indicator(" << imp.name() << ", " << imp.getParameter() << ")"; os << "Indicator(" << imp.name() << ", " << imp.getParameter() << ")";

View File

@ -305,4 +305,5 @@ inline KData IndicatorImp::getContext() const {
} }
} /* namespace hku */ } /* namespace hku */
#endif /* INDICATORIMP_H_ */ #endif /* INDICATORIMP_H_ */

View File

@ -21,14 +21,16 @@
* @see test_all.cpp * @see test_all.cpp
*/ */
#ifdef BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE test_all #define BOOST_TEST_MODULE test_all
#include <boost/test/unit_test.hpp> #include <boost/test/unit_test.hpp>
// Linux下在Eclipse中编译必须使用下面的头文件使用bjam不需要否则提示无法找到“main“函数原因未知
// 但bjam编译时会有告警虽然可以编译通过。
// Windows下如果使用下面的头文件将无法编译。
#ifdef ECLIPSE_GCC
#include <boost/test/included/unit_test.hpp>
#endif
using namespace boost::unit_test; using namespace boost::unit_test;
#else
#include <boost/test/included/unit_test.hpp>
boost::unit_test::test_suite* init_unit_test_suite(int /*argc*/, char* /*argv*/[])
{
std::cout << "using obsolete init" << std::endl;
return 0;
}
#endif /* #ifdef BOOST_TEST_DYN_LINK */

View File

@ -13,6 +13,8 @@ target("unit-test")
set_kind("phony") set_kind("phony")
end end
--add_defines("BOOST_TEST_DYN_LINK")
add_packages("fmt", "spdlog") add_packages("fmt", "spdlog")
add_includedirs("..") add_includedirs("..")
@ -56,6 +58,8 @@ target("small-test")
add_packages("fmt", "spdlog") add_packages("fmt", "spdlog")
add_includedirs("..") add_includedirs("..")
--add_defines("BOOST_TEST_DYN_LINK")
if is_plat("windows") then if is_plat("windows") then
add_cxflags("-wd4267") add_cxflags("-wd4267")
add_cxflags("-wd4251") add_cxflags("-wd4251")

View File

@ -10,6 +10,9 @@ option_end()
add_includedirs("../hikyuu_cpp") add_includedirs("../hikyuu_cpp")
-- Can't use static boost.python lib, the function that using 'arg' will load failed!
--add_defines("BOOST_PYTHON_STATIC_LIB")
if is_plat("windows") then if is_plat("windows") then
add_defines("HKU_API=__declspec(dllimport)") add_defines("HKU_API=__declspec(dllimport)")
end end

View File

@ -22,31 +22,31 @@ function main(target)
if "hikyuu" == targetname then if "hikyuu" == targetname then
os.cp(targetfile, './hikyuu') os.cp(targetfile, './hikyuu')
if is_plat("windows") then if is_plat("windows") then
os.cp("$(env BOOST_LIB)/boost_date_time*.dll", './hikyuu') --os.cp("$(env BOOST_LIB)/boost_date_time*.dll", './hikyuu')
os.cp("$(env BOOST_LIB)/boost_filesystem*.dll", './hikyuu') --os.cp("$(env BOOST_LIB)/boost_filesystem*.dll", './hikyuu')
os.cp("$(env BOOST_LIB)/boost_python3*.dll", './hikyuu') os.cp("$(env BOOST_LIB)/boost_python3*.dll", './hikyuu')
os.cp("$(env BOOST_LIB)/boost_serialization*.dll", './hikyuu') --os.cp("$(env BOOST_LIB)/boost_serialization*.dll", './hikyuu')
os.cp("$(env BOOST_LIB)/boost_system*.dll", './hikyuu') --os.cp("$(env BOOST_LIB)/boost_system*.dll", './hikyuu')
os.cp("$(projectdir)/hikyuu_extern_libs/pkg/hdf5.pkg/lib/release/$(plat)/$(arch)/*.dll", './hikyuu') os.cp("$(projectdir)/hikyuu_extern_libs/pkg/hdf5.pkg/lib/release/$(plat)/$(arch)/*.dll", './hikyuu')
os.cp("$(projectdir)/hikyuu_extern_libs/pkg/mysql.pkg/lib/release/$(plat)/$(arch)/*.dll", './hikyuu') os.cp("$(projectdir)/hikyuu_extern_libs/pkg/mysql.pkg/lib/release/$(plat)/$(arch)/*.dll", './hikyuu')
return return
end end
if is_plat("linux") then if is_plat("linux") then
os.cp("$(env BOOST_LIB)/libboost_date_time*.so.*", './hikyuu') --os.cp("$(env BOOST_LIB)/libboost_date_time*.so.*", './hikyuu')
os.cp("$(env BOOST_LIB)/libboost_filesystem*.so.*", './hikyuu') --os.cp("$(env BOOST_LIB)/libboost_filesystem*.so.*", './hikyuu')
os.cp("$(env BOOST_LIB)/libboost_python3*.so.*", './hikyuu') os.cp("$(env BOOST_LIB)/libboost_python3*.so.*", './hikyuu')
os.cp("$(env BOOST_LIB)/libboost_serialization*.so.*", './hikyuu') --os.cp("$(env BOOST_LIB)/libboost_serialization*.so.*", './hikyuu')
os.cp("$(env BOOST_LIB)/libboost_system*.so.*", './hikyuu') --os.cp("$(env BOOST_LIB)/libboost_system*.so.*", './hikyuu')
return return
end end
if is_plat("macosx") then if is_plat("macosx") then
os.cp("$(env BOOST_LIB)/libboost_date_time*.dylib", './hikyuu') --os.cp("$(env BOOST_LIB)/libboost_date_time*.dylib", './hikyuu')
os.cp("$(env BOOST_LIB)/libboost_filesystem*.dylib", './hikyuu') --os.cp("$(env BOOST_LIB)/libboost_filesystem*.dylib", './hikyuu')
os.cp("$(env BOOST_LIB)/libboost_python3*.dylib", './hikyuu') os.cp("$(env BOOST_LIB)/libboost_python3*.dylib", './hikyuu')
os.cp("$(env BOOST_LIB)/libboost_serialization*.dylib", './hikyuu') --os.cp("$(env BOOST_LIB)/libboost_serialization*.dylib", './hikyuu')
os.cp("$(env BOOST_LIB)/libboost_system*.dylib", './hikyuu') --os.cp("$(env BOOST_LIB)/libboost_system*.dylib", './hikyuu')
return return
end end

View File

@ -20,32 +20,32 @@ function main(target)
end end
if is_plat("windows") then if is_plat("windows") then
os.cp("$(env BOOST_LIB)/boost_date_time*.dll", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/") --os.cp("$(env BOOST_LIB)/boost_date_time*.dll", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
os.cp("$(env BOOST_LIB)/boost_filesystem*.dll", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/") --os.cp("$(env BOOST_LIB)/boost_filesystem*.dll", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
os.cp("$(env BOOST_LIB)/boost_serialization*.dll", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/") --os.cp("$(env BOOST_LIB)/boost_serialization*.dll", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
os.cp("$(env BOOST_LIB)/boost_system*.dll", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/") --os.cp("$(env BOOST_LIB)/boost_system*.dll", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
os.cp("$(env BOOST_LIB)/boost_unit_test_framework*.dll", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/") --os.cp("$(env BOOST_LIB)/boost_unit_test_framework*.dll", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
os.cp("$(projectdir)/hikyuu_extern_libs/pkg/hdf5.pkg/lib/release/$(plat)/$(arch)/*.dll","$(buildir)/$(mode)/$(plat)/$(arch)/lib/") os.cp("$(projectdir)/hikyuu_extern_libs/pkg/hdf5.pkg/lib/release/$(plat)/$(arch)/*.dll","$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
os.cp("$(projectdir)/hikyuu_extern_libs/pkg/mysql.pkg/lib/release/$(plat)/$(arch)/*.dll", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/") os.cp("$(projectdir)/hikyuu_extern_libs/pkg/mysql.pkg/lib/release/$(plat)/$(arch)/*.dll", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
end end
if is_plat("linux") then if is_plat("linux") then
os.cp("$(env BOOST_LIB)/libboost_date_time*.so.*", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/") --os.cp("$(env BOOST_LIB)/libboost_date_time*.so.*", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
os.cp("$(env BOOST_LIB)/libboost_filesystem*.so.*", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/") --os.cp("$(env BOOST_LIB)/libboost_filesystem*.so.*", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
os.cp("$(env BOOST_LIB)/libboost_serialization*.so.*", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/") --os.cp("$(env BOOST_LIB)/libboost_serialization*.so.*", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
os.cp("$(env BOOST_LIB)/libboost_system*.so.*", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/") os.cp("$(env BOOST_LIB)/libboost_system*.so.*", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
os.cp("$(env BOOST_LIB)/libboost_unit_test_framework*.so.*", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/") --os.cp("$(env BOOST_LIB)/libboost_unit_test_framework*.so.*", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
end end
if is_plat("macosx") then if is_plat("macosx") then
os.cp("$(env BOOST_LIB)/libboost_date_time*.dylib", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/") --os.cp("$(env BOOST_LIB)/libboost_date_time*.dylib", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
os.cp("$(env BOOST_LIB)/libboost_filesystem*.dylib", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/") --os.cp("$(env BOOST_LIB)/libboost_filesystem*.dylib", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
os.cp("$(env BOOST_LIB)/libboost_serialization*.dylib", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/") --os.cp("$(env BOOST_LIB)/libboost_serialization*.dylib", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
os.cp("$(env BOOST_LIB)/libboost_system*.dylib", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/") --os.cp("$(env BOOST_LIB)/libboost_system*.dylib", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
os.cp("$(env BOOST_LIB)/libboost_unit_test_framework*.dylib", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/") --os.cp("$(env BOOST_LIB)/libboost_unit_test_framework*.dylib", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
-- macOSX下unit_test_framework依赖于timer和chrono -- macOSX下unit_test_framework依赖于timer和chrono
os.cp("$(env BOOST_LIB)/libboost_timer*.dylib", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/") --os.cp("$(env BOOST_LIB)/libboost_timer*.dylib", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
os.cp("$(env BOOST_LIB)/libboost_chrono*.dylib", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/") --os.cp("$(env BOOST_LIB)/libboost_chrono*.dylib", "$(buildir)/$(mode)/$(plat)/$(arch)/lib/")
end end
end end

View File

@ -79,10 +79,16 @@ def build_boost():
os.chdir(current_boost_root) os.chdir(current_boost_root)
if not os.path.exists('b2.exe'): if not os.path.exists('b2.exe'):
os.system('bootstrap.bat') os.system('bootstrap.bat')
os.system('b2 release link=shared address-model=64 -j 4 --with-python --with-date_time --with-filesystem --with-system --with-serialization --with-test') os.system('b2 release link=static runtime-link=shared address-model=64 -j 4 --with-date_time'
' --with-filesystem --with-system --with-serialization --with-test')
os.system('b2 release link=shared runtime-link=shared address-model=64 -j 4 --with-python')
os.chdir(current_dir) os.chdir(current_dir)
else: else:
cmd = 'cd {boost} ; if [ ! -f "b2" ]; then ./bootstrap.sh ; fi; ./b2 release link=shared address-model=64 -j 4 --with-python --with-date_time --with-filesystem --with-system --with-serialization --with-test; cd {current}'.format(boost=current_boost_root, current=current_dir) cmd = 'cd {boost} ; if [ ! -f "b2" ]; then ./bootstrap.sh ; fi; '\
'./b2 release link=shared address-model=64 -j 4 --with-python; '\
'./b2 release link=static address-model=64 -j 4 --with-date_time '\
'--with-filesystem --with-system --with-serialization --with-test; '\
'cd {current}'.format(boost=current_boost_root, current=current_dir)
os.system(cmd) os.system(cmd)

View File

@ -38,7 +38,8 @@ add_includedirs("hikyuu_extern_libs/inc")
add_includedirs("$(env BOOST_ROOT)") add_includedirs("$(env BOOST_ROOT)")
add_linkdirs("$(env BOOST_LIB)") add_linkdirs("$(env BOOST_LIB)")
add_defines("BOOST_ALL_DYN_LINK") -- modifed to use boost static library, except boost.python
--add_defines("BOOST_ALL_DYN_LINK")
if is_host("linux") then if is_host("linux") then
if is_arch("x86_64") then if is_arch("x86_64") then
@ -73,14 +74,14 @@ if is_plat("windows") then
add_cxflags("-MD") add_cxflags("-MD")
elseif is_mode("debug") then elseif is_mode("debug") then
add_cxflags("-Gs", "-RTC1") add_cxflags("-Gs", "-RTC1")
add_cxflags("-MDd") add_cxflags("-MDd")
end end
end end
if not is_plat("windows") then if not is_plat("windows") then
-- disable some compiler errors -- disable some compiler errors
add_cxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing") add_cxflags("-Wno-error=deprecated-declarations", "-fno-strict-aliasing")
add_cxflags("-ftemplate-depth-500", "-pthread") add_cxflags("-ftemplate-depth=1023", "-pthread")
add_shflags("-pthread") add_shflags("-pthread")
add_ldflags("-pthread") add_ldflags("-pthread")
end end