This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Combining C and C++ source files in a DS-5 project using the Altera Baremetal GNU toolchain

I'm using DS-5 Intel Soc FPGA Edition Version 5.28.1

I want to create a DS-5 project that will automatically compile .C files with GCC and .CPP files with G++.

I can get the project to work by manually selecting the C++ compiler for .CPP files, but it is painful to set up/maintain and creates some errors in the error log.......is there an easier way to do this ?

The steps I am following for a v simple example project is:

File->New->C/C++ Project
Select C Managed Build Template - as documentation suggests that a C++ project will push all files through C++ compiler.
Select Project type: Empty Project
Select Toolchain: Altera Baremetal GCC

Add a .C file and a .CPP file to the project. Change linker from arm-altera-eabi-gcc to arm-altera-eabi-g++.
The .CPP file is not compiled when I attempt to build the project.
Therefore I:
Right click on .CPP file - select Properties->C/C++ Build->Tool Chain Editor. Change Select tool from --NO TOOL-- to GCC C++ Compiler.
Right click on .CPP file - select Properties->C/C++ Build->Settings->Tool Settings->GCC C++ Compiler->Command: change from g++ to arm-altera-eabi-g++

Note here that  the GCC C++ Compiler options not show the Target option like it does if I create a C++ project or like it does for the GCC compiler.

I can now compile and link OK.
arm-altera-eabi-gcc is used for the .C file and arm-altera-eabi-g++ is used for the .CPP file.

However for every CPP file I add, I need to go and select the C++ compiler again - how do I get it to just compile .CPP files with G++ and .C files with GCC ?

Also the C++ compiler still does not appear in the C/C++ Build->Settings->Tool Settings list, so any compiler options I need to change manually for each .CPP file included.

I also get 2 entries in the error log when I build the project ( despite the compile/link working OK) complaining about:

Error: Cannot run program "G++": Launching failed from the org.eclipse.cdt.core plug-in.

What G++ is this referring to - I have configured the C++ compile command as arm-altera-eabi-g++.

The error log generated is:

eclipse.buildId=4.6.3.M20170301-0400
java.version=1.8.0_45
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_GB
Framework arguments: -product com.arm.ds.altera
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product com.arm.ds.altera

org.eclipse.cdt.core
Error
Thu May 16 07:57:30 BST 2019
Error: Cannot run program "g++": Launching failed

java.io.IOException: Cannot run program "g++": Launching failed
at org.eclipse.cdt.utils.spawner.Spawner.exec(Spawner.java:349)
at org.eclipse.cdt.utils.spawner.Spawner.<init>(Spawner.java:91)
at org.eclipse.cdt.utils.spawner.ProcessFactory.exec(ProcessFactory.java:91)
at org.eclipse.cdt.core.CommandLauncher.execute(CommandLauncher.java:194)
at org.eclipse.cdt.internal.core.BuildRunnerHelper.build(BuildRunnerHelper.java:263)
at org.eclipse.cdt.make.internal.core.scannerconfig2.DefaultRunSIProvider.invokeProvider(DefaultRunSIProvider.java:144)
at org.eclipse.cdt.build.internal.core.scannerconfig.jobs.CfgSCJobsUtil$1.run(CfgSCJobsUtil.java:94)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.runtime.Platform.run(Platform.java:826)
at org.eclipse.cdt.build.internal.core.scannerconfig.jobs.CfgSCJobsUtil.getProviderScannerInfo(CfgSCJobsUtil.java:105)
at org.eclipse.cdt.build.core.scannerconfig.ScannerConfigBuilder.build(ScannerConfigBuilder.java:206)
at org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager.loadPathInfo(CfgDiscoveredPathManager.java:298)
at org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager.getDiscoveredInfo(CfgDiscoveredPathManager.java:177)
at org.eclipse.cdt.managedbuilder.internal.dataprovider.ProfileInfoProvider.getEntryValues(ProfileInfoProvider.java:65)
at org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildEntryStorage.getDiscoveredEntries(BuildEntryStorage.java:200)
at org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildEntryStorage.putEntriesToLevel(BuildEntryStorage.java:190)
at org.eclipse.cdt.core.settings.model.util.AbstractEntryStorage.initCache(AbstractEntryStorage.java:71)
at org.eclipse.cdt.core.settings.model.util.AbstractEntryStorage.getEntries(AbstractEntryStorage.java:34)
at org.eclipse.cdt.managedbuilder.internal.dataprovider.BuildLanguageData.getEntries(BuildLanguageData.java:161)
at org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData.getEntriesToCopy(CDefaultLanguageData.java:101)
at org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData.createStore(CDefaultLanguageData.java:92)
at org.eclipse.cdt.core.settings.model.extension.impl.CDefaultLanguageData.copySettingsFrom(CDefaultLanguageData.java:85)
at org.eclipse.cdt.internal.core.settings.model.CLanguageSettingCache.copySettingsFrom(CLanguageSettingCache.java:47)
at org.eclipse.cdt.internal.core.settings.model.CLanguageSettingCache.<init>(CLanguageSettingCache.java:42)
at org.eclipse.cdt.internal.core.settings.model.CFileDescriptionCache.copyLanguageData(CFileDescriptionCache.java:40)
at org.eclipse.cdt.core.settings.model.extension.impl.CDefaultFileData.copyDataFrom(CDefaultFileData.java:58)
at org.eclipse.cdt.internal.core.settings.model.CFileDescriptionCache.<init>(CFileDescriptionCache.java:35)
at org.eclipse.cdt.internal.core.settings.model.CConfigurationDescriptionCache.copyFileData(CConfigurationDescriptionCache.java:223)
at org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData.copySettingsFrom(CDefaultConfigurationData.java:126)
at org.eclipse.cdt.internal.core.settings.model.CConfigurationDescriptionCache.applyData(CConfigurationDescriptionCache.java:193)
at org.eclipse.cdt.internal.core.settings.model.CProjectDescription.applyDatas(CProjectDescription.java:216)
at org.eclipse.cdt.internal.core.settings.model.SetCProjectDescriptionOperation.executeOperation(SetCProjectDescriptionOperation.java:98)
at org.eclipse.cdt.internal.core.model.CModelOperation.execute(CModelOperation.java:341)
at org.eclipse.cdt.internal.core.model.CModelOperation.run(CModelOperation.java:607)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
at org.eclipse.cdt.internal.core.model.CModelOperation.runOperation(CModelOperation.java:638)
at org.eclipse.cdt.internal.core.settings.model.AbstractCProjectDescriptionStorage.setProjectDescription(AbstractCProjectDescriptionStorage.java:203)
at org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionStorageManager.setProjectDescription(CProjectDescriptionStorageManager.java:149)
at org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager.setProjectDescription(CProjectDescriptionManager.java:853)
at org.eclipse.cdt.managedbuilder.internal.core.BuildSettingsUtil.checkApplyDescription(BuildSettingsUtil.java:211)
at org.eclipse.cdt.managedbuilder.core.ManagedBuildManager.updateCoreSettings(ManagedBuildManager.java:1575)
at org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager$1.run(CfgDiscoveredPathManager.java:154)
at org.eclipse.cdt.internal.core.model.BatchOperation.executeOperation(BatchOperation.java:36)
at org.eclipse.cdt.internal.core.model.CModelOperation.execute(CModelOperation.java:341)
at org.eclipse.cdt.internal.core.model.CModelOperation.run(CModelOperation.java:607)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
at org.eclipse.cdt.core.model.CoreModel.run(CoreModel.java:1219)
at org.eclipse.cdt.core.model.CoreModel.run(CoreModel.java:1180)
at org.eclipse.cdt.build.internal.core.scannerconfig.CfgDiscoveredPathManager.updateCoreSettings(CfgDiscoveredPathManager.java:157)
at org.eclipse.cdt.build.core.scannerconfig.ScannerConfigBuilder.build(ScannerConfigBuilder.java:125)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:735)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:246)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:301)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:304)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:360)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:383)
at org.eclipse.core.internal.resources.Workspace.buildInternal(Workspace.java:487)
at org.eclipse.core.internal.resources.Workspace.build(Workspace.java:406)
at org.eclipse.ui.actions.BuildAction$1.runInWorkspace(BuildAction.java:285)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:39)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)