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

x64 on MingW doest not work #241

Open
SamCZ opened this issue Aug 2, 2021 · 21 comments
Open

x64 on MingW doest not work #241

SamCZ opened this issue Aug 2, 2021 · 21 comments

Comments

@SamCZ
Copy link

SamCZ commented Aug 2, 2021

CMAKE_CL_64 variable is only for Microsoft Visual Studio I needed to force this if to make it compile to x64
https://github.com/MADEAPPS/newton-dynamics/blob/master/newton-3.14/CMakeLists.txt#L154
https://github.com/MADEAPPS/newton-dynamics/blob/master/newton-4.00/CMakeLists.txt#L196

@JulioJerez
Copy link
Contributor

JulioJerez commented Aug 3, 2021

I do no understand, variable CMAKE_CL_64
if under MINGW brake.

for windows the is use the pointer size. which I believe works since I use every time.
for Linux or Unix systems the define is at line 85 on teh same file
and using this

#if (BUILD_64)
if (CMAKE_CL_64)
message("build 64 bit")
add_definitions(-D_POSIX_VER_64)
else (CMAKE_CL_64)
message("build 32 bit")
add_definitions(-D_POSIX_VER)
endif (CMAKE_CL_64)

I just changed to use CMAKE_CL_64 instead of pointer size BUILD_64

what platform are you building for?

@SamCZ
Copy link
Author

SamCZ commented Aug 3, 2021

I use GCC on windows x64 with MingW that was downloaded from MSYS2 (mingw-w64-x86_64-gcc), for me the variable CMAKE_CL_64 is not defined.

EDIT: Idk why, but some of the demos newton-3.14 are crashing on nullptr entity when iterating from DemoEntityManager, but almost every one is working on sanbox.

@JulioJerez
Copy link
Contributor

JulioJerez commented Aug 3, 2021 via email

@SamCZ
Copy link
Author

SamCZ commented Aug 3, 2021

Are you saying that the make file generated by cmake does not add the
defines for 64 bit build?

Yes because CMAKE_CL_64 is not defined, so for me it goes to this branch https://github.com/MADEAPPS/newton-dynamics/blob/master/newton-3.14/CMakeLists.txt#L159

I forced X64 by adding -DCMAKE_CL_64=ON argument to cmake command.

I will try today run the 4.xx samples if it is working.

@JulioJerez
Copy link
Contributor

JulioJerez commented Aug 3, 2021 via email

@SamCZ
Copy link
Author

SamCZ commented Aug 3, 2021

ok thanks, I will try the 4.0 and write you an comment.

The reason I firstly used 3.14 its because my college from work said that the 4.0 is work in progress so he would use the 3.14, but nevertheless I will try the 4.0, thanks for the info.

@JulioJerez
Copy link
Contributor

JulioJerez commented Aug 3, 2021 via email

@SamCZ
Copy link
Author

SamCZ commented Aug 3, 2021

C:/Sam/Projects/EmberSky/lib/Aurora/lib/newton-dynamics/newton-4.00/sdk/dCore/dTypes.h: In constructor 'dAtomic<T>::dAtomic()': C:/Sam/Projects/EmberSky/lib/Aurora/lib/newton-dynamics/newton-4.00/sdk/dCore/dTypes.h:353:13: error: 'val' was not declared in this scope; did you mean 'm_val'? 353 | : m_val(T(val)) | ^~~ | m_val

https://github.com/MADEAPPS/newton-dynamics/blob/master/newton-4.00/sdk/dCore/dTypes.h#L313

EDIT: Do you have discord or something where we could chat ?

@SamCZ
Copy link
Author

SamCZ commented Aug 3, 2021

Next error:
image

C:\Sam\Projects\EmberSky\lib\Aurora\lib\newton-dynamics\newton-4.00\sdk\dNewton\dModels\dVehicle\ndMultiBodyVehicle.cpp:618:69: error: no matching function for call to 'dMax(double, float)' 618 | dFloat32 den = dMax (dAbs (entry1->m_speed - entry0->m_speed), 1.0f);

@SamCZ
Copy link
Author

SamCZ commented Aug 3, 2021

Btw I had enabled NEWTON_DOUBLE_PRECISION
Rn I'm trying it without it

@SamCZ
Copy link
Author

SamCZ commented Aug 3, 2021

I just compiled ndSandbox, but I needed to make some fixes in the cmake files

@JulioJerez
Copy link
Contributor

Ok the error are fixed.
Please try again.
any reason why you buidl single tread?

using a thread the engine will run concurrent with you app. what is mean is that as a long as you run on a system with more than one core, an dthe frame update takes less that the graphics.
you get the physics for free.
the method is implement similar to the way opengl implement concurrent update.

what fixes you made to the cmake file?

@JulioJerez
Copy link
Contributor

I also fixed the errors and warning in double.
I see there is a bug with collsion somewhere when using double precision.
I saw the truck pass right over the floor.

I will check it out.

@JulioJerez
Copy link
Contributor

I set up a repro for debug the bug using double.
I will fix later, but you can keep building let us see if there are more errors.

so far it seems fine using 32 bit floats.

@JulioJerez
Copy link
Contributor

Ok I found the bug with double.
It is wit the Simd solvers.
they are some place where I do things liek this

			dInt32 temp = -1;
			m_mask = dVector(*(dFloat32*)(&temp));

as you can see with 32 bit float that code works,
but in 64 bit is fail because only the lower 32 bit of the double are set.

I nee to search for all teh place were the operation Select is using and see it it is using a mask trick and replace with teh correct code. I will be fix some time today. meantime the float 32 should be working fine.

@JulioJerez
Copy link
Contributor

ok double precision is fixed now.

@SamCZ
Copy link
Author

SamCZ commented Aug 4, 2021

Sorry I went to sleep last night,
So first I needed to fix adding glfw subdirectory here https://github.com/MADEAPPS/newton-dynamics/blob/master/newton-4.00/thirdParty/CMakeLists.txt#L17 because i already had loaded glfw in my engine.

The first fix is:

if (MSVC OR MINGW)
        if(NOT TARGET glfw)
		add_subdirectory(glfw)
	endif()
endif(MSVC OR MINGW)

After this it compiled properly, but when I tried to compile the samples, there was and error with wrong folder in cmake for OpenAL .lib file in https://github.com/MADEAPPS/newton-dynamics/blob/master/newton-4.00/applications/ndSandbox/CMakeLists.txt#L74
I changed ${CMAKE_SOURCE_DIR} to ${PROJECT_SOURCE_DIR} at every place in this file (this was cause by adding newton-dynamics as a submodule to subdirectory at my project (C:\Sam\Projects\EmberSky\lib\Aurora\lib\newton-dynamics\newton-4.00)).

So when this fix was introduced and everything was built I tried to include newton in my engine, but there was an issue that some includes for core and others were missing because you dont use target_inclue_directories in your cmake, so I did another fix.
Here https://github.com/MADEAPPS/newton-dynamics/blob/master/newton-4.00/sdk/CMakeLists.txt#L107

I added these lines:

target_include_directories(ndNewton PUBLIC dCore/)
target_include_directories(ndNewton PUBLIC dNewton/)
target_include_directories(ndNewton PUBLIC dTinyxml/)
target_include_directories(ndNewton PUBLIC dCollision/)
target_include_directories(ndNewton PUBLIC dNewton/dJoints/)
target_include_directories(ndNewton PUBLIC dNewton/dModels/)
target_include_directories(ndNewton PUBLIC dNewton/dModels/dVehicle)
target_include_directories(ndNewton PUBLIC dNewton/dModels/dCharacter)

If I forgot something I will comment here after I get home.


any reason why you buidl single tread?

It was just because option("NEWTON_BUILD_SINGLE_THREADED" "multi threaded" OFF) is weirdly commented,
the option say that if you set this to ON it will disable multithreading, but the commend say otherwise. I will use multithreading.

Last night I managed to get two cubes collide in my engine with your lib, so I'm happy now. Thanks for the help, this library is very nice and I will add your logo to my game when I have splashscreen and credits implemented.

@JulioJerez
Copy link
Contributor

JulioJerez commented Aug 4, 2021 via email

@SamCZ
Copy link
Author

SamCZ commented Aug 7, 2021

Hi, just updated repo and enabled doubles and this error pops out

                 from C:\Sam\Projects\EmberSky\lib\Aurora\lib\newton-dynamics\newton-4.00\sdk\dCollision\ndCollisionStdafx.h:30,
                 from C:\Sam\Projects\EmberSky\lib\Aurora\lib\newton-dynamics\newton-4.00\sdk\dCollision\ndBody.cpp:23:
C:/Sam/Projects/EmberSky/lib/Aurora/lib/newton-dynamics/newton-4.00/sdk/dCore/dSpatialVector.h:97:15: error: member 'dBigVector dSpatialVector::<unnamed union>::<unnamed struct>::m_low' with constructor not allowed in anonymous aggregate
   97 |    dBigVector m_low;
      |               ^~~~~
C:/Sam/Projects/EmberSky/lib/Aurora/lib/newton-dynamics/newton-4.00/sdk/dCore/dSpatialVector.h:98:15: error: member 'dBigVector dSpatialVector::<unnamed union>::<unnamed struct>::m_high' with constructor not allowed in anonymous aggregate
   98 |    dBigVector m_high;
      |               ^~~~~~```

@JulioJerez
Copy link
Contributor

please see my comment in the pull request.

@SamCZ
Copy link
Author

SamCZ commented Aug 8, 2021

It builds fine now, thanks.

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