Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ubuntu编译出错,求救! #281

Closed
LYP857 opened this issue Nov 30, 2023 · 8 comments
Closed

ubuntu编译出错,求救! #281

LYP857 opened this issue Nov 30, 2023 · 8 comments

Comments

@LYP857
Copy link

LYP857 commented Nov 30, 2023

y@ty-virtual-machine:~/Desktop/opt/3dtiles$ cargo build --release
Updating crates.io index
warning: spurious network error (3 tries remaining): [7] Couldn't connect to server (Failed to connect to static.crates.io port 443 after 21070 ms: Connection refused)
Downloaded atty v0.2.14
Downloaded strsim v0.8.0
Downloaded quick-error v1.2.3
Downloaded cfg-if v1.0.0
Downloaded bitflags v0.7.0
Downloaded scopeguard v1.2.0
Downloaded log v0.3.9
Downloaded memoffset v0.9.0
Downloaded termcolor v1.4.0
Downloaded textwrap v0.11.0
Downloaded serde-xml-rs v0.2.1
Downloaded either v1.9.0
Downloaded autocfg v1.1.0
Downloaded bitflags v1.3.2
Downloaded unicode-width v0.1.11
Downloaded env_logger v0.5.13
Downloaded itoa v1.0.9
Downloaded humantime v1.3.0
Downloaded iana-time-zone v0.1.58
Downloaded crossbeam-deque v0.8.3
Downloaded vec_map v0.8.2
Downloaded ansi_term v0.12.1
Downloaded byteorder v1.5.0
Downloaded quote v1.0.33
Downloaded unicode-ident v1.0.12
Downloaded crossbeam-utils v0.8.16
Downloaded log v0.4.20
Downloaded xml-rs v0.3.6
Downloaded proc-macro2 v1.0.70
Downloaded ryu v1.0.15
Downloaded num-traits v0.2.17
Downloaded crossbeam-epoch v0.9.15
Downloaded serde_derive v1.0.193
Downloaded cc v1.0.83
Downloaded rayon-core v1.12.0
Downloaded serde v1.0.193
Downloaded memchr v2.6.4
Downloaded serde_json v1.0.108
Downloaded rayon v1.8.0
Downloaded aho-corasick v1.1.2
Downloaded clap v2.34.0
Downloaded chrono v0.4.31
Downloaded regex v1.10.2
Downloaded syn v2.0.39
Downloaded regex-syntax v0.8.2
Downloaded regex-automata v0.4.3
Downloaded libc v0.2.150
Downloaded 47 crates (4.2 MB) in 1m 19s
Compiling autocfg v1.1.0
Compiling libc v0.2.150
Compiling proc-macro2 v1.0.70
Compiling unicode-ident v1.0.12
Compiling memoffset v0.9.0
Compiling crossbeam-utils v0.8.16
Compiling quote v1.0.33
Compiling crossbeam-epoch v0.9.15
Compiling cfg-if v1.0.0
Compiling syn v2.0.39
Compiling serde v1.0.193
Compiling scopeguard v1.2.0
Compiling memchr v2.6.4
Compiling aho-corasick v1.1.2
Compiling serde_derive v1.0.193
Compiling num-traits v0.2.17
Compiling rayon-core v1.12.0
Compiling log v0.4.20
Compiling regex-syntax v0.8.2
Compiling cc v1.0.83
Compiling atty v0.2.14
Compiling regex-automata v0.4.3
Compiling crossbeam-deque v0.8.3
Compiling bitflags v0.7.0
Compiling quick-error v1.2.3
Compiling unicode-width v0.1.11
Compiling serde_json v1.0.108
Compiling textwrap v0.11.0
Compiling humantime v1.3.0
Compiling xml-rs v0.3.6
Compiling regex v1.10.2
Compiling _3dtile v0.1.0 (/home/ty/Desktop/opt/3dtiles)
Compiling log v0.3.9
Compiling itoa v1.0.9
Compiling vec_map v0.8.2
Compiling bitflags v1.3.2
Compiling either v1.9.0
Compiling strsim v0.8.0
Compiling ryu v1.0.15
Compiling iana-time-zone v0.1.58
Compiling ansi_term v0.12.1
Compiling termcolor v1.4.0
Compiling env_logger v0.5.13
Compiling clap v2.34.0
Compiling chrono v0.4.31
Compiling rayon v1.8.0
Compiling serde-xml-rs v0.2.1
The following warnings were emitted during compilation:

warning: ./src/tileset.cpp: In function ‘bool wkt_convert(char*, double*, char*)’:
warning: ./src/tileset.cpp:40:23: warning: ‘OGRErr OGRSpatialReference::importFromWkt(char**)’ is deprecated [-Wdeprecated-declarations]
warning: 40 | inRs.importFromWkt(&wkt);
warning: | ~~~~~~~~~~~~~~~~~~^~~~~~
warning: In file included from ./src/GeoTransform.h:2,
warning: from ./src/tileset.cpp:13:
warning: /usr/include/gdal/ogr_spatialref.h:208:17: note: declared here
warning: 208 | OGRErr importFromWkt( char ** )
warning: | ^~~~~~~~~~~~~
warning: In file included from ./src/shp23dtile.cpp:6:
warning: ./src/earcut.hpp: In member function ‘mapbox::detail::Earcut::Node* mapbox::detail::Earcut::findHoleBridge(mapbox::detail::Earcut::Node*, mapbox::detail::Earcut::Node*)’:
warning: ./src/earcut.hpp:460:23: error: ‘numeric_limits’ is not a member of ‘std’
warning: 460 | double qx = -std::numeric_limits::infinity();
warning: | ^~~~~~~~~~~~~~
warning: ./src/earcut.hpp:460:38: error: expected primary-expression before ‘double’
warning: 460 | double qx = -std::numeric_limits::infinity();
warning: | ^~~~~~
warning: ./src/earcut.hpp:489:26: error: ‘numeric_limits’ is not a member of ‘std’
warning: 489 | double tanMin = std::numeric_limits::infinity();
warning: | ^~~~~~~~~~~~~~
warning: ./src/earcut.hpp:489:41: error: expected primary-expression before ‘double’
warning: 489 | double tanMin = std::numeric_limits::infinity();
warning: | ^~~~~~

error: failed to run custom build command for _3dtile v0.1.0 (/home/ty/Desktop/opt/3dtiles)

Caused by:
process didn't exit successfully: /home/ty/Desktop/opt/3dtiles/target/release/build/_3dtile-b994adcbfc723bfb/build-script-build (exit status: 1)
--- stdout
TARGET = Some("x86_64-unknown-linux-gnu")
OPT_LEVEL = Some("3")
HOST = Some("x86_64-unknown-linux-gnu")
cargo:rerun-if-env-changed=CXX_x86_64-unknown-linux-gnu
CXX_x86_64-unknown-linux-gnu = None
cargo:rerun-if-env-changed=CXX_x86_64_unknown_linux_gnu
CXX_x86_64_unknown_linux_gnu = None
cargo:rerun-if-env-changed=HOST_CXX
HOST_CXX = None
cargo:rerun-if-env-changed=CXX
CXX = None
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
cargo:rerun-if-env-changed=CXXFLAGS_x86_64-unknown-linux-gnu
CXXFLAGS_x86_64-unknown-linux-gnu = None
cargo:rerun-if-env-changed=CXXFLAGS_x86_64_unknown_linux_gnu
CXXFLAGS_x86_64_unknown_linux_gnu = None
cargo:rerun-if-env-changed=HOST_CXXFLAGS
HOST_CXXFLAGS = None
cargo:rerun-if-env-changed=CXXFLAGS
CXXFLAGS = None
running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "./src" "-I" "./src/osg" "-std=c++11" "-o" "/home/ty/Desktop/opt/3dtiles/target/release/build/_3dtile-18b6323a83c4a031/out/./src/tileset.o" "-c" "./src/tileset.cpp"
cargo:warning=./src/tileset.cpp: In function ‘bool wkt_convert(char*, double*, char*)’:

cargo:warning=./src/tileset.cpp:40:23: warning: ‘OGRErr OGRSpatialReference::importFromWkt(char**)’ is deprecated [-Wdeprecated-declarations]

cargo:warning= 40 | inRs.importFromWkt(&wkt);

cargo:warning= | ~~~~~~~~~~~~~~~~~~^~~~~~

cargo:warning=In file included from ./src/GeoTransform.h:2,

cargo:warning= from ./src/tileset.cpp:13:

cargo:warning=/usr/include/gdal/ogr_spatialref.h:208:17: note: declared here

cargo:warning= 208 | OGRErr importFromWkt( char ** )

cargo:warning= | ^~~~~~~~~~~~~

exit status: 0
running: "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "./src" "-I" "./src/osg" "-std=c++11" "-o" "/home/ty/Desktop/opt/3dtiles/target/release/build/_3dtile-18b6323a83c4a031/out/./src/shp23dtile.o" "-c" "./src/shp23dtile.cpp"
cargo:warning=In file included from ./src/shp23dtile.cpp:6:

cargo:warning=./src/earcut.hpp: In member function ‘mapbox::detail::Earcut::Node* mapbox::detail::Earcut::findHoleBridge(mapbox::detail::Earcut::Node*, mapbox::detail::Earcut::Node*)’:

cargo:warning=./src/earcut.hpp:460:23: error: ‘numeric_limits’ is not a member of ‘std’

cargo:warning= 460 | double qx = -std::numeric_limits::infinity();

cargo:warning= | ^~~~~~~~~~~~~~

cargo:warning=./src/earcut.hpp:460:38: error: expected primary-expression before ‘double’

cargo:warning= 460 | double qx = -std::numeric_limits::infinity();

cargo:warning= | ^~~~~~

cargo:warning=./src/earcut.hpp:489:26: error: ‘numeric_limits’ is not a member of ‘std’

cargo:warning= 489 | double tanMin = std::numeric_limits::infinity();

cargo:warning= | ^~~~~~~~~~~~~~

cargo:warning=./src/earcut.hpp:489:41: error: expected primary-expression before ‘double’

cargo:warning= 489 | double tanMin = std::numeric_limits::infinity();

cargo:warning= | ^~~~~~

exit status: 1

--- stderr

error occurred: Command "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-m64" "-I" "./src" "-I" "./src/osg" "-std=c++11" "-o" "/home/ty/Desktop/opt/3dtiles/target/release/build/_3dtile-18b6323a83c4a031/out/./src/shp23dtile.o" "-c" "./src/shp23dtile.cpp" with args "c++" did not execute successfully (status code exit status: 1).

warning: build failed, waiting for other jobs to finish...
是我的gdalt太新了吗
ty@ty-virtual-machine:~/Desktop/opt/3dtiles$ gdalinfo --version
GDAL 3.4.3, released 2022/04/22
已经按照教程打开tileset.cpp里面的宏定义

@LYP857
Copy link
Author

LYP857 commented Nov 30, 2023

这是改完后的tileset.cpp文件
#ifdef _WIN32
#include <gdal/ogr_spatialref.h>
#include <gdal/ogrsf_frmts.h>
#endif

#include
#include
#include
#include
#include

#include "extern.h"
#include "GeoTransform.h"

///////////////////////
static const double pi = std::acos(-1);

extern "C" bool epsg_convert(int insrs, double* val, char* path) {
//CPLSetConfigOption("GDAL_DATA", path);
OGRSpatialReference inRs,outRs;
inRs.importFromEPSG(insrs);
outRs.importFromEPSG(4326);
OGRCoordinateTransformation *poCT = OGRCreateCoordinateTransformation( &inRs, &outRs );
GeoTransform::Init(poCT, val);
if (poCT) {
if (poCT->Transform( 1, val, val + 1)) {
// poCT will be used later so don't delete it
// delete poCT;
return true;
}
// delete poCT;
}
return false;
}

extern "C" bool wkt_convert(char* wkt, double* val, char* path) {
//CPLSetConfigOption("GDAL_DATA", path);
OGRSpatialReference inRs,outRs;
inRs.importFromWkt(&wkt);
outRs.importFromEPSG(4326);
OGRCoordinateTransformation *poCT = OGRCreateCoordinateTransformation( &inRs, &outRs );
GeoTransform::Init(poCT, val);
if (poCT) {
if (poCT->Transform( 1, val, val + 1)) {
// delete poCT;
return true;
}
// delete poCT;
}
return false;
}

extern "C"
{
double degree2rad(double val) {
return val * pi / 180.0;
}
double lati_to_meter(double diff) {
return diff / 0.000000157891;
}

double longti_to_meter(double diff, double lati) {
	return diff / 0.000000156785 * std::cos(lati);
}

double meter_to_lati(double m) {
	return m * 0.000000157891;
}

double meter_to_longti(double m, double lati) {
	return m * 0.000000156785 / std::cos(lati);
}

}

std::vector transfrom_xyz(double radian_x, double radian_y, double height_min){
double ellipsod_a = 40680631590769;
double ellipsod_b = 40680631590769;
double ellipsod_c = 40408299984661.4;

const double pi = std::acos(-1);
double xn = std::cos(radian_x) * std::cos(radian_y);
double yn = std::sin(radian_x) * std::cos(radian_y);
double zn = std::sin(radian_y);

double x0 = ellipsod_a * xn;
double y0 = ellipsod_b * yn;
double z0 = ellipsod_c * zn;
double gamma = std::sqrt(xn*x0 + yn*y0 + zn*z0);
double px = x0 / gamma;
double py = y0 / gamma;
double pz = z0 / gamma;

double dx = xn * height_min;
double dy = yn * height_min;
double dz = zn * height_min;

std::vector<double> east_mat = {-y0,x0,0};
std::vector<double> north_mat = {
    (y0*east_mat[2] - east_mat[1]*z0),
    (z0*east_mat[0] - east_mat[2]*x0),
    (x0*east_mat[1] - east_mat[0]*y0)
};
double east_normal = std::sqrt(
    east_mat[0]*east_mat[0] + 
    east_mat[1]*east_mat[1] + 
    east_mat[2]*east_mat[2]
    );
double north_normal = std::sqrt(
    north_mat[0]*north_mat[0] + 
    north_mat[1]*north_mat[1] + 
    north_mat[2]*north_mat[2]
    );

std::vector<double> matrix = {
    east_mat[0] / east_normal,
    east_mat[1] / east_normal,
    east_mat[2] / east_normal,
    0,
    north_mat[0] / north_normal,
    north_mat[1] / north_normal,
    north_mat[2] / north_normal,
    0,
    xn,
    yn,
    zn,
    0,
    px + dx,
    py + dy,
    pz + dz,
    1
};
return matrix;

}

extern "C" void transform_c(double center_x, double center_y, double height_min, double* ptr) {
double radian_x = degree2rad( center_x );
double radian_y = degree2rad( center_y );
std::vector v = transfrom_xyz(radian_x, radian_y, height_min);
std::memcpy(ptr, v.data(), v.size() * 8);
}

bool write_tileset_box(
Transform* trans, Box& box,
double geometricError,
const char* b3dm_file,
const char* json_file) {

std::vector<double> matrix;
if (trans) {
    matrix = transfrom_xyz(trans->radian_x,trans->radian_y,trans->min_height);
}
std::string json_txt = "{\"asset\": {\
    \"version\": \"0.0\",\
    \"gltfUpAxis\": \"Y\"\
},\
\"geometricError\":";
json_txt += std::to_string(geometricError);
json_txt += ",\"root\": {";
std::string trans_str = "\"transform\": [";
if (trans) {
    for (int i = 0; i < 15 ; i++) {
        trans_str += std::to_string(matrix[i]);
        trans_str += ",";
    }
    trans_str += "1],";
    json_txt += trans_str;
}
json_txt += "\"boundingVolume\": {\
    \"box\": [";
for (int i = 0; i < 11 ; i++) {
    json_txt += std::to_string(box.matrix[i]);
    json_txt += ",";
}
json_txt += std::to_string(box.matrix[11]);

char last_buf[512];
sprintf(last_buf,"]},\"geometricError\": %f,\
    \"refine\": \"REPLACE\",\
    \"content\": {\
        \"uri\": \"%s\"}}}", geometricError, b3dm_file);

json_txt += last_buf;

bool ret = write_file(json_file, json_txt.data(), (unsigned long)json_txt.size());
if (!ret) {
    LOG_E("write file %s fail", json_file);
}
return ret;

}

bool write_tileset_region(
Transform* trans,
Region& region,
double geometricError,
const char* b3dm_file,
const char* json_file)
{
std::vector matrix;
if (trans) {
matrix = transfrom_xyz(trans->radian_x,trans->radian_y,trans->min_height);
}
std::string json_txt = "{"asset": {
"version": "0.0",
"gltfUpAxis": "Y"
},
"geometricError":";
json_txt += std::to_string(geometricError);
json_txt += ","root": {";
std::string trans_str = ""transform": [";
if (trans) {
for (int i = 0; i < 15 ; i++) {
trans_str += std::to_string(matrix[i]);
trans_str += ",";
}
trans_str += "1],";
json_txt += trans_str;
}
json_txt += ""boundingVolume": {
"region": [";
double* pRegion = (double*)&region;
for (int i = 0; i < 5 ; i++) {
json_txt += std::to_string(pRegion[i]);
json_txt += ",";
}
json_txt += std::to_string(pRegion[5]);

char last_buf[512];
sprintf(last_buf,"]},\"geometricError\": %f,\
    \"refine\": \"REPLACE\",\
    \"content\": {\
        \"uri\": \"%s\"}}}", geometricError, b3dm_file);

json_txt += last_buf;

bool ret = write_file(json_file, json_txt.data(), (unsigned long)json_txt.size());
if (!ret) {
    LOG_E("write file %s fail", json_file);
}
return ret;

}

/*/
bool write_tileset(
double radian_x, double radian_y,
double tile_w, double tile_h,
double height_min, double height_max,
double geometricError,
const char
filename, const char
full_path)
{

double ellipsod_a = 40680631590769;
double ellipsod_b = 40680631590769;
double ellipsod_c = 40408299984661.4;

const double pi = std::acos(-1);
double xn = std::cos(radian_x) * std::cos(radian_y);
double yn = std::sin(radian_x) * std::cos(radian_y);
double zn = std::sin(radian_y);

double x0 = ellipsod_a * xn;
double y0 = ellipsod_b * yn;
double z0 = ellipsod_c * zn;
double gamma = std::sqrt(xn*x0 + yn*y0 + zn*z0);
double px = x0 / gamma;
double py = y0 / gamma;
double pz = z0 / gamma;
double dx = x0 * height_min;
double dy = y0 * height_min;
double dz = z0 * height_min;

std::vector<double> east_mat = {-y0,x0,0};
std::vector<double> north_mat = {
    (y0*east_mat[2] - east_mat[1]*z0),
    (z0*east_mat[0] - east_mat[2]*x0),
    (x0*east_mat[1] - east_mat[0]*y0)
};
double east_normal = std::sqrt(
    east_mat[0]*east_mat[0] + 
    east_mat[1]*east_mat[1] + 
    east_mat[2]*east_mat[2]
    );
double north_normal = std::sqrt(
    north_mat[0]*north_mat[0] + 
    north_mat[1]*north_mat[1] + 
    north_mat[2]*north_mat[2]
    );

std::vector<double> matrix = {
    east_mat[0] / east_normal,
    east_mat[1] / east_normal,
    east_mat[2] / east_normal,
    0,
    north_mat[0] / north_normal,
    north_mat[1] / north_normal,
    north_mat[2] / north_normal,
    0,
    xn,
    yn,
    zn,
    0,
    px + dx,
    py + dy,
    pz + dz,
    1
};

std::vector<double> region = {
    radian_x - meter_to_longti(tile_w / 2, radian_y),
    radian_y - meter_to_lati(tile_h / 2),
    radian_x + meter_to_longti(tile_w / 2, radian_y),
    radian_y + meter_to_lati(tile_h / 2),
    0,
    height_max
};

std::string json_txt = "{\"asset\": {\
    \"version\": \"0.0\",\
    \"gltfUpAxis\": \"Y\"\
},\
\"geometricError\":";
json_txt += std::to_string(geometricError);
json_txt += ",\"root\": {\
    \"transform\": [";
for (int i = 0; i < 15 ; i++) {
    json_txt += std::to_string(matrix[i]);
    json_txt += ",";
}
json_txt += "1],\
\"boundingVolume\": {\
\"region\": [";
for (int i = 0; i < 5 ; i++) {
    json_txt += std::to_string(region[i]);
    json_txt += ",";
}
json_txt += std::to_string(region[5]);

char last_buf[512];
sprintf(last_buf,"]},\"geometricError\": %f,\
    \"refine\": \"REPLACE\",\
    \"content\": {\
    \"uri\": \"%s\"}}}", geometricError, filename);

json_txt += last_buf;

bool ret = write_file(full_path, json_txt.data(), (unsigned long)json_txt.size());
if (!ret) {
    LOG_E("write file %s fail", filename);
}
return ret;

}

@fanvanzh
Copy link
Owner

fanvanzh commented Dec 1, 2023

warning: ./src/earcut.hpp:460:23: error: ‘numeric_limits’ is not a member of ‘std’
warning: 460 | double qx = -std::numeric_limits::infinity();
warning: | ^~~~~~~~~~~~~~
warning: ./src/earcut.hpp:460:38: error: expected primary-expression before ‘double’
warning: 460 | double qx = -std::numeric_limits::infinity();
warning: | ^~~~~~
warning: ./src/earcut.hpp:489:26: error: ‘numeric_limits’ is not a member of ‘std’
warning: 489 | double tanMin = std::numeric_limits::infinity();
warning: | ^~~~~~~~~~~~~~
warning: ./src/earcut.hpp:489:41: error: expected primary-expression before ‘double’

没安装 C++ 开发环境?用什么编译器,支持C++什么版本?

@LYP857
Copy link
Author

LYP857 commented Dec 1, 2023

使用的是Ubuntu 22.04,并且安装了GNU编译器集合(GCC)的版本为11.4.0。
GCC 11.4.0是一个较新的版本,它支持C++17、C++14、C++11和C++98标准
image

@LYP857
Copy link
Author

LYP857 commented Dec 1, 2023

我又用了centos7.3的进行编译,编译成功后,使用但是会报ERROR: 2023-12-01 11:19:19 - epsg convert failed!
image
查看依赖返回以下,我是缺少什么依赖吗

[root@localhost release]# ldd _3dtile linux-vdso.so.1 => (0x00007fff533f8000) libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f4ea47cd000) libosg.so.202 => not found libosgDB.so.202 => not found libosgUtil.so.202 => not found libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f4ea45b5000) librt.so.1 => /lib64/librt.so.1 (0x00007f4ea43ad000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f4ea4191000) libm.so.6 => /lib64/libm.so.6 (0x00007f4ea3e8e000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f4ea3c8a000) libc.so.6 => /lib64/libc.so.6 (0x00007f4ea38bc000) /lib64/ld-linux-x86-64.so.2 (0x00007f4ea5043000)

@LYP857
Copy link
Author

LYP857 commented Dec 1, 2023

image
补个图方便看,对于c++编译这些不太懂,请大佬赐教

@LYP857
Copy link
Author

LYP857 commented Dec 1, 2023

image
环境变量不报找不到了,但是进行osgb转3dtiles是还是报了ERROR: 2023-12-01 16:11:14 - epsg convert failed!
还有哪一个步骤错了吗?

@fanvanzh
Copy link
Owner

fanvanzh commented Dec 1, 2023

linux 源码里没带 gdal 库支持,可以参考下issue里其他人编译成功的说明

@fanvanzh
Copy link
Owner

已增加 Ubuntu 的 github actions, 参考主页的 Build 指南。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants