Azure / azure-sphere-samples

Samples for Azure Sphere
Other
222 stars 200 forks source link

Trouble compiling large Cmake project in Visual Studio #87

Closed k2nsloos closed 4 years ago

k2nsloos commented 4 years ago

Hi all,

I'm having trouble with my own CMake based Azure Sphere project using, using Visual Studio. The CMake File contains many source file entries. The compilation of the individual object files succeeds, but the final two commands fail. (Presumably the linking phase.)

afbeelding

Checking the build directory, I found these files present as expected: afbeelding

But when comparing to smaller projects I noticed that no response file (.rsp) is generated in the smaller projects and compilation succeeds (for those smaller projects).

[110/113] cmd.exe /C "cd . && C:\PROGRA~2\MI3C21~1\Sysroots\2_BETA~1\tools\gcc\ARFCD8~1.EXE -B "C:/Program Files (x86)/Microsoft Azure Sphere SDK/Sysroots/2+Beta1905/tools/gcc" -march=armv7ve -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 --sysroot="C:/Program Files (x86)/Microsoft Azure Sphere SDK/Sysroots/2+Beta1905" -nodefaultlibs -pie -Wl,--no-undefined -Wl,--gc-sections @CMakeFiles\BdrPlatform.rsp -o BdrPlatform.out && cd ." FAILED: BdrPlatform.out cmd.exe /C "cd . && C:\PROGRA~2\MI3C21~1\Sysroots\2_BETA~1\tools\gcc\ARFCD8~1.EXE -B "C:/Program Files (x86)/Microsoft Azure Sphere SDK/Sysroots/2+Beta1905/tools/gcc" -march=armv7ve -mthumb -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a7 --sysroot="C:/Program Files (x86)/Microsoft Azure Sphere SDK/Sysroots/2+Beta1905" -nodefaultlibs -pie -Wl,--no-undefined -Wl,--gc-sections @CMakeFiles\BdrPlatform.rsp -o BdrPlatform.out && cd ."

Any help, ideas and/or thoughts on the matter would be extreme welcome!

richardtaylorrt commented 4 years ago

Hi - we note there's a missing "/" temp1 temp2

This may be an issue in your CMakeLists.txt (please check) or it could be a problem with our CMake toolchain. If you suspect this, please could you help us narrow the problem down:

If this is specific to running your code in Visual Studio, another option would also be to ask the Visual Studio Developer Community.

k2nsloos commented 4 years ago

Hi,

First of all thanks for you for your reply and your time.

Next regarding your comments:

I forked the example repository and modified the hello world example, in such a way that it fails compilation. See: https://github.com/k2nsloos/azure-sphere-samples/tree/setupNotWorkingExample/Samples/HelloWorld/HelloWorld_HighLevelApp_CMake

Basically I added lots of source files under myLibrary/source/myfunctionXXX.c, each source file contains a single function, that does absolutely nothing.

For example myLibrary/source/myfunction123.c:

#include <myLibrary.h>

void myFunction123(void)
{

}

The regular CMakeLists.txt will fail compilation (at least on my machine), while the CMakeLists_works.txt does work. I hope this helps with narrowing it down...

Edit: Unfortunately I am not allowed to share the code of my original project.

jophippe commented 4 years ago

Thank you for bringing this to our attention! This error is caused by CMake improperly handling response file generation by default when cross-compiling Windows to GCC, which we never noticed until now. There is a workaround that we're implementing in our toolchain for an upcoming release. Follow these steps to try it out yourself:

After saving and closing the file, reopening the project in VS, and waiting for cache generation to finish, build should work as expected. Hopefully this helps!

k2nsloos commented 4 years ago

Yes!, that worked! Thank you very very very much!!!