Author Topic: How could I compile a project mixed with c&c++ code/ˆwith out makefile/‰?  (Read 4704 times)

Bi Chin

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
I'm using GCC&FreeRTOS(a embedded rtos written with pure C)with stm32 develop,but I'd like to write driver and task in c++ code.
For certain reason,freertos can't be compiled with c++ compiler.The only way is compile freertos with gcc then compile other code with g++,then link all the object file with g++.

This can be done with a makefile,but I'm wondering :Is it possible to build such kind of project with out a makefile in slickedit?
In the project type "Other C/C++",".c"&“.cpp” file and ".s" file can have different compile command.
Could it be more specific?I mean different compile command for ".C" and ".CPP" file?

Matthew

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 990
  • Hero Points: 44
There *is* a way, but unfortunately this facility is not exposed in the user interface, and the process is not documented. You would need to manually add a <Rules> section to each of your configurations by hand-editing the project's .vpj file(s). In that Rules section is where you define the alternate command lines based upon the file extension.

I have created a sample project (attached as a zip file) to serve as a reference. I created this by first running the GNU C/C++ wizard to create the starter project. I added the *.c compiler rule to simply substitute gcc for g++ in the command line.


Bi Chin

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
 :D
Hey Matthew,thanks a lot!This sample does help!

john.dehelian

  • Junior Community Member
  • Posts: 9
  • Hero Points: 1
I had the same question and tried the same thing but it didn't work because I am compiling with a makefile generated by slick edit. But I did the following and it worked, even when adding new files to the project. Note I'm building for ARM too but did all that with the user interface.

Code: [Select]
# -----Begin user-editable area-----
COMPILE1=/home/john/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-gcc -c   -g -o "$(OUTDIR)/$(*F).o" $(CFG_INC) $<
...
# -----End user-editable area-----
$(OUTDIR)/%.o : %.c
$(COMPILE1)


john.dehelian

  • Junior Community Member
  • Posts: 9
  • Hero Points: 1
Update: As long as you make the change in the *.vpj first as suggested by Mathew before adding *.c files to the project, then it works with make files generated by slick edit too. Thanks. Slickedit is great!

Matthew

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 990
  • Hero Points: 44
Glad the sample helped you. And thanks for sharing your experience on working with makefiles.