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

Build failed with custom opencv on RockyLinux #518

Closed
d0m1n1kr opened this issue Nov 29, 2023 · 3 comments
Closed

Build failed with custom opencv on RockyLinux #518

d0m1n1kr opened this issue Nov 29, 2023 · 3 comments

Comments

@d0m1n1kr
Copy link

The build failed with the following error:

  error occurred: Command "c++" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-gdwarf-4" "-fno-omit-frame-pointer" "-m64" "-I" "/home/dominik/.cargo/registry/src/index.crates.io-6f17d22bba15001f/opencv-0.88.1/src_cpp" "-I" "/home/dominik/rust-imager/target/debug/build/opencv-7c08d579b87f9d27/out" "-I" "." "-I" "/usr/local/include/opencv4" "-Wall" "-Wextra" "-std=c++14" "-Wno-deprecated-declarations" "-Wno-deprecated-copy" "-Wno-unused-parameter" "-Wno-sign-compare" "-Wno-comment" "-Wno-unused-variable" "-Wno-ignored-qualifiers" "-Wno-return-type-c-linkage" "-Wno-overloaded-virtual" "-o" "/home/dominik/rust-imager/target/debug/build/opencv-7c08d579b87f9d27/out/04cdb4ef15dc4ab0-freetype.o" "-c" "/home/dominik/rust-imager/target/debug/build/opencv-7c08d579b87f9d27/out/freetype.cpp" with args "c++" did not execute successfully (status code exit status: 1).

refering to

  cargo:warning=/home/dominik/rust-imager/target/debug/build/opencv-7c08d579b87f9d27/out/freetype.cpp: In function ‘void cv_freetype_FreeType2_loadFontData_charX_size_t_int(cv::freetype::FreeType2*, void**, size_t, int, ResultVoid*)’:
  cargo:warning=/home/dominik/rust-imager/target/debug/build/opencv-7c08d579b87f9d27/out/freetype.cpp:25:30: error: variable or field ‘ret_1’ declared void
  cargo:warning=   25 |                         void ret_1 = ;
  cargo:warning=      |                              ^~~~~
  cargo:warning=/home/dominik/rust-imager/target/debug/build/opencv-7c08d579b87f9d27/out/freetype.cpp:25:38: error: expected primary-expression before ‘;’ token
  cargo:warning=   25 |                         void ret_1 = ;
  cargo:warning=      |                                      ^
  cargo:warning=/home/dominik/rust-imager/target/debug/build/opencv-7c08d579b87f9d27/out/freetype.cpp:27:28: error: ‘ret_1’ was not declared in this scope
  cargo:warning=   27 |                         Ok(ret_1, ocvrs_return);
  cargo:warning=      |                            ^~~~~
  cargo:warning=At global scope:

The generated source code of freetype.cpp is:

	void cv_freetype_FreeType2_loadFontData_charX_size_t_int(cv::freetype::FreeType2* instance, void** pBuf, size_t bufSize, int idx, ResultVoid* ocvrs_return) {
		try {
			char* pBuf_out = new char[1024]();
			instance->loadFontData(pBuf_out, bufSize, idx);
			*pBuf = ocvrs_create_string(pBuf_out);
			void ret_1 = ;
			delete[] pBuf_out;
			Ok(ret_1, ocvrs_return);
		} OCVRS_CATCH(ResultVoid, ocvrs_return);
	}

The signature of the loadFontData from the freetype.hpp file is

    CV_WRAP virtual void loadFontData(char* pBuf, size_t bufSize, int idx) = 0;

Obviously somethings goes wrong in code generation with the void** parameter.

When I remove the line from the freetype.hpp header file, it builds successfully.

  1. Operating system
    Linux version 5.14.0-284.30.1.el9_2.x86_64 (mockbuild@iad1-prod-build001.bld.equ.rockylinux.org) (gcc (GCC) 11.3.1 20221121 (Red Hat 11.3.1-4), GNU ld version 2.35.2-37.el9) Added a few Mat functions and corresponding primitives #1 SMP PREEMPT_DYNAMIC Sat Sep 16 09:55:41 UTC 2023
  2. The way you installed OpenCV: package, official binary distribution, manual compilation, etc.
    Build with current 4.8.1 sources (including contrib modules).
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_GENERATE_PKGCONFIG=ON -D 
OPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.x/modules -D WITH_FREETYPE=ON ../opencv-4.x
  1. OpenCV version
    4.8.1
  2. rustc version (rustc --version)
    rustc 1.74.0 (79e9716c9 2023-11-13)
  3. Attach the full output of the following command from your project directory:
    RUST_BACKTRACE=full cargo build -vv 2> build_log.txt > build_log.txt
    build_log.txt
@twistedfall
Copy link
Owner

Looks like you're using git version of opencv_contrib, not a release version, because this function doesn't exist in the latest 4.8.1 release: https://github.com/opencv/opencv_contrib/blob/4.8.1/modules/freetype/include/opencv2/freetype.hpp#L85

So to solve this, use the latest release version for opencv_contrib, but this problem will come up with the next release so I'll work on fixing it, thank you for the report and analysis!

@d0m1n1kr
Copy link
Author

You are right. I used this tutorial to install the latest version and I thought the zip files include the latest tag, not the release branch.

@twistedfall
Copy link
Owner

This should now be fixed in 0.88.5

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