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

ITK failed to build due to error C2169: 'lrintf': intrinsic function, cannot be defined with MSVC on windows #1967

Closed
spacelg opened this issue Aug 28, 2020 · 10 comments · Fixed by #2388
Labels
status:Backlog Postponed without a fixed deadline type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances

Comments

@spacelg
Copy link

spacelg commented Aug 28, 2020

Hi All,

ITK failed to build due to error C2169: 'lrintf': intrinsic function, cannot be defined with MSVC on windows. It can be reproduced on master branch latest commit 26079ef. Could you please help look at this? Thanks a lot!

Repro Steps:

  1. git clone https://github.com/InsightSoftwareConsortium/ITK.git F:\gitP\InsightSoftwareConsortium\ITK
  2. Open VS2019 x64 command prompt as admin and browse to F:\gitP\InsightSoftwareConsortium\ITK
  3. Apply itk_bug623130.patch
  4. mkdir build_amd64 and cd build_amd64
  5. cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.18362.0 -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=ON -DBUILD_EXAMPLES=OFF ..
  6. set CL=/D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING %CL%
  7. msbuild /m /p:Platform=x64 /p:Configuration=Release All_BUILD.vcxproj /t:Rebuild

Build_log:
build.log
itk_bug623130.patch:
itk_bug623130.zip

ErrorMessage:
188>F:\gitP\InsightSoftwareConsortium\ITK\Modules\ThirdParty\OpenJPEG\src\openjpeg\opj_includes.h(106,35): error C2169: 'lrintf': intrinsic function, cannot be defined [F:\gitP\InsightSoftwareConsortium\ITK\build_amd64\Modules\ThirdParty\OpenJPEG\src\openjpeg\itkopenjpeg.vcxproj]

@spacelg spacelg added the type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances label Aug 28, 2020
@dzenanz
Copy link
Member

dzenanz commented Aug 28, 2020

This looks like a problem in OpenJPEG, and it should be updated [1][2]. @malaterre it looks like you wrote OpenJPEG's CMake buildsystem. Do you have time to update it in ITK?

@spacelg
Copy link
Author

spacelg commented Sep 18, 2020

@dzenanz , Thanks for your info. This issue can still reproduced on ITK latest reversion. @malaterre could you please look at this issue?

Thanks,
Lin

@malaterre
Copy link
Member

$ git grep  OPENJPEG_VERSION | tail -1
Modules/ThirdParty/OpenJPEG/src/openjpeg/openjpeg.h:#define OPENJPEG_VERSION "1.2.0"

What do you exactly expect from me ? I am not touching OpenJPEG release from ~2007:

@malaterre
Copy link
Member

malaterre commented Sep 18, 2020

BTW lrintf has been renamed opj_lrintf upstream for a while

@dzenanz
Copy link
Member

dzenanz commented Sep 18, 2020

We need to update the version of OpenJPEG which is bundled with ITK. As third party libraries are not overly related to ITK, even people not proficient with ITK should be able to update them. @spacelg could you give it a try?

@spacelg
Copy link
Author

spacelg commented Sep 25, 2020

@dzenanz Thanks for your info and help. I tried to apply a patch for ../Modules/ThirdParty/OpenJPEG/src/openjpeg/opj_includes.h as below. It can build pass. Thank you very much.

diff --git a/Modules/ThirdParty/OpenJPEG/src/openjpeg/opj_includes.h b/Modules/ThirdParty/OpenJPEG/src/openjpeg/opj_includes.h
index e75a220d4d..60d185e233 100644
--- a/Modules/ThirdParty/OpenJPEG/src/openjpeg/opj_includes.h
+++ b/Modules/ThirdParty/OpenJPEG/src/openjpeg/opj_includes.h
@@ -92,7 +92,7 @@ Most compilers implement their own version of this keyword ...

/* MSVC 64bits doesn't support _asm */
#if !defined(_WIN64)
-static INLINE long lrintf(float f){
+static INLINE long opj_lrintf(float f){
int i;

_asm{
@@ -103,7 +103,7 @@ static INLINE long lrintf(float f){
return i;
}
#else
-static INLINE long lrintf(float x){
+static INLINE long opj_lrintf(float x){
long r;
if (x>=0.f)
{

@dzenanz
Copy link
Member

dzenanz commented Sep 25, 2020

Could you turn that into a PR?

@stale
Copy link

stale bot commented Jan 23, 2021

This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions.

@stale stale bot added the status:Backlog Postponed without a fixed deadline label Jan 23, 2021
yoda-vid added a commit to yoda-vid/SimpleElastix that referenced this issue Apr 7, 2021
ITK fixed a critical build error when compiling OpenJPEG as reported here:
InsightSoftwareConsortium/ITK#1967

Update ITK to the current latest version, which includes this fix.
N-Dekker added a commit to SuperElastix/elastix that referenced this issue Apr 7, 2021
ITK fixed a critical build error when compiling OpenJPEG as reported here, by spacelg:

"ITK failed to build due to error C2169: 'lrintf': intrinsic function, cannot be defined with MSVC on windows"
issue InsightSoftwareConsortium/ITK#1967

Update ITK to version 5.2.0 (whose release is about to be announced), which includes this fix.

Following pull request SuperElastix/SimpleElastix#425 by David Young (yoda-vid)
yoda-vid added a commit to yoda-vid/SimpleElastix that referenced this issue Apr 8, 2021
ITK fixed a critical build error when compiling OpenJPEG as reported here:
InsightSoftwareConsortium/ITK#1967

Update ITK to the current latest version, which includes this fix.
@N-Dekker
Copy link
Contributor

N-Dekker commented Apr 9, 2021

@spacelg @dzenanz @malaterre Is there a specific reason why it was decided not to upgrade OpenJPEG? The lrintf problem is properly fixed with commit uclouvain/openjpeg@c423cc8#diff-91c70438e617694516cb0ab60919517ff67034354cf73070cb243a7680411f89R126 which is included with OpenJPEG v2.1.1 (July 2016)

@dzenanz
Copy link
Member

dzenanz commented Apr 9, 2021

Yes. The specific reason is: that is expected to take non-trivial effort. Of course, anyone can volunteer to do it. Skill required is mostly CMake-related, not really ITK-related.

N-Dekker added a commit to SuperElastix/elastix that referenced this issue May 29, 2021
ITK fixed a critical build error when compiling OpenJPEG as reported here, by spacelg:

"ITK failed to build due to error C2169: 'lrintf': intrinsic function, cannot be defined with MSVC on windows"
issue InsightSoftwareConsortium/ITK#1967

Update ITK to version 5.2.0 (whose release is about to be announced), which includes this fix.

Following pull request SuperElastix/SimpleElastix#425 by David Young (yoda-vid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:Backlog Postponed without a fixed deadline type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants