Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 8 Replies) Include directory in shared library project (Read 6106 times)
RonOhmer
Junior Member
**
Offline


Posts: 29
Joined: Feb 10th, 2015
Include directory in shared library project
Sep 27th, 2017 at 1:23pm
Print Post  
Actually I have 2 questions:
1. How do I add include directories to the g++ call? I have tried using the visual studio directories (Which seems to update intellisense, but not the build), and I have tried adding via -I pointing to my copied directory, for example:
-I"External\StandardCplusplus"

That shows up in the build, but doesnt seem to work, as you can see here:
Code
Select All
\4.8.3-2014q1\bin\arm-none-eabi-g++" -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DVM_DEBUG_BREAKPAUSE -DVM_DEBUGGER_TYPE=VM_DEBUGGER_TYPE_UART -DVM_DEBUGGER_TYPE_SERIALUSB=18 -DVM_DEBUGGER_TYPE_USBAPI=17 -DVM_DEBUGGER_TYPE_NET_UDP=16 -DVM_DEBUGGER_TYPE_HARDWARESERIAL3=15 -DVM_DEBUGGER_TYPE_HARDWARESERIAL2=14 -DVM_DEBUGGER_TYPE_HARDWARESERIAL1=13 -DVM_DEBUGGER_TYPE_CDCSerialClass=12 -DVM_DEBUGGER_TYPE_COSA=11 -DVM_DEBUGGER_TYPE_Uart=10 -DVM_DEBUGGER_TYPE_NET_CONSOLE=9 -DVM_DEBUGGER_TYPE_TTYUART=8 -DVM_DEBUGGER_TYPE_USBSERIAL=7 -DVM_DEBUGGER_TYPE_USART=6 -DVM_DEBUGGER_TYPE_UART=5 -DVM_DEBUGGER_TYPE_TEENSY=4 -DVM_DEBUGGER_TYPE_USB=3 -DVM_DEBUGGER_TYPE_FASTSERIAL=2 -DVM_DEBUGGER_TYPE_SOFTWARESERIAL=1 -DVM_DEBUGGER_TYPE_HARDWARESERIAL=0 -DVM_DEBUG_BANDWIDTH_THROTTLE_MS=100 -DVM_DEBUG_ENABLE=1 -DVM_DEBUG  -fpermissive -I"External\StandardCplusplus"   -Dprintf=iprintf -w -x c++ -E -CC -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L -DARDUINO=10804 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON -DUSB_MANUFACTURER="\"Arduino LLC\"" -DUSB_PRODUCT="\"Arduino Due\"" ystem/libsam" ystem/CMSIS/CMSIS/Include/" ystem/CMSIS/Device/ATMEL/" ores\arduino" ariants\arduino_due_x" ibraries\SPI\src" -I"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\53ggn0bh.0i3\Micro Platforms\default\debuggers\VM_DBG" \External\StandardCplusplus\associative_base.cpp" -o "nul"

associative_base.cpp: 20:28: fatal error: associative_base: No such file or directory
   #include "associative_base"
   compilation terminated
Debug build failed for project 'uWindowsTest'
 


Is it possible to ${} the build dir in an include?
2nd question or request.  It would be nice if we could set includes in shared library projects, that got propagated up to the project that uses them.

THANKS!
Ron
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Include directory in shared library project
Reply #1 - Sep 27th, 2017 at 1:54pm
Print Post  
Hi,

Visual Micro is Arduino compatible so the Arduino IDE rules apply.

Thanks
  
Back to top
WWW  
IP Logged
 
RonOhmer
Junior Member
**
Offline


Posts: 29
Joined: Feb 10th, 2015
Re: Include directory in shared library project
Reply #2 - Sep 27th, 2017 at 2:47pm
Print Post  
Ok, so how would I include a directory?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Include directory in shared library project
Reply #3 - Sep 27th, 2017 at 3:02pm
Print Post  
It's not so easy and normally not required.

It's not possible to understand the structure you want to work with or where the include will point to in relation to the library and your project code.

You should also ensure you are not confusing this post with the word "library". Do you mean an Arduino Library or a shared project? Do you know how Arduino Libraries work?

Have you ever created an Arduino library before?
  
Back to top
WWW  
IP Logged
 
RonOhmer
Junior Member
**
Offline


Posts: 29
Joined: Feb 10th, 2015
Re: Include directory in shared library project
Reply #4 - Sep 27th, 2017 at 3:06pm
Print Post  
Sigh, we arent communicating well.

What I want to do is include a directory (I misspoke when I said library).

So, if I included said code as an Arduino style library the includes would be taken care of.

What I have is a Shared Library and a necessary include inside of it.

For example:
SharedLibrary/External/LIB

I want to include LIB in my build, the issue is when I do -I"SharedLibrary/External/LIB" it doesnt propagate out correctly.  When it is building code in the shared library, as opposed to the project that includes it, I get include not found errors (Which I dont in the base project).

So, obviously -I wont work with the relative directory, is there a way to push the -I down to the shared library?
  
Back to top
 
IP Logged
 
RonOhmer
Junior Member
**
Offline


Posts: 29
Joined: Feb 10th, 2015
Re: Include directory in shared library project
Reply #5 - Sep 27th, 2017 at 3:07pm
Print Post  
Oh, its "Shared Code' not shared library.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Include directory in shared library project
Reply #6 - Sep 27th, 2017 at 3:21pm
Print Post  
Okay so lets forget the word library?

You can add a compiler -I in the Visual Micro project properties flags or includes property. However this often causes confusion because all you get is a compiler include. The compiler will not look at the include and compile the code in the included folder. So if all you need are references in a .h then it might be okay.

However you could make the external code a Visual Studio shared project and then add a Reference to the arduino project. Visual Micro will detect this and copy the external code into the temp directory tree used for compile. In that case the following might work for you.

I am unclear from your post the actual structure of your external code. I will assume that some files exist in the folder called "SharedLibrary" therefore SharedLibrary will be where our shared project is created

ArduinoProject1
   ArduinoProject1.ino
   ArduinoCpp.cpp

SharedLibrary
   some.cpp
   SharedLibrary/External/LIB
      someheader.h

In this case the files in SharedLibrary will be located in the same folder as ArduinoProject1.ino during compile.  Our ArduinoProject1.ino code can reference files from \LIB with a relative path #include "External/LIB/someheader.h"

A compiler include of -I"{project_folder}/External/LIB" might also work

  
Back to top
WWW  
IP Logged
 
RonOhmer
Junior Member
**
Offline


Posts: 29
Joined: Feb 10th, 2015
Re: Include directory in shared library project
Reply #7 - Sep 27th, 2017 at 3:29pm
Print Post  
I think the -I{...} will work

I dont think {project_folder} is the correct variable though, it is coming out as blank in the compile.
  
Back to top
 
IP Logged
 
RonOhmer
Junior Member
**
Offline


Posts: 29
Joined: Feb 10th, 2015
Re: Include directory in shared library project
Reply #8 - Sep 27th, 2017 at 3:32pm
Print Post  
What I am looking for is the variable that represents the bold here in the command line:

\4.8.3-2014q1\bin\arm-none-eabi-g++" -c -g -Os -w -std=gnu++11 -ffunction-sections -fdata-sections -nostdlib -fno-threadsafe-statics --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DVM_DEBUG_BREAKPAUSE -DVM_DEBUGGER_TYPE=VM_DEBUGGER_TYPE_UART -DVM_DEBUGGER_TYPE_SERIALUSB=18 -DVM_DEBUGGER_TYPE_USBAPI=17 -DVM_DEBUGGER_TYPE_NET_UDP=16 -DVM_DEBUGGER_TYPE_HARDWARESERIAL3=15 -DVM_DEBUGGER_TYPE_HARDWARESERIAL2=14 -DVM_DEBUGGER_TYPE_HARDWARESERIAL1=13 -DVM_DEBUGGER_TYPE_CDCSerialClass=12 -DVM_DEBUGGER_TYPE_COSA=11 -DVM_DEBUGGER_TYPE_Uart=10 -DVM_DEBUGGER_TYPE_NET_CONSOLE=9 -DVM_DEBUGGER_TYPE_TTYUART=8 -DVM_DEBUGGER_TYPE_USBSERIAL=7 -DVM_DEBUGGER_TYPE_USART=6 -DVM_DEBUGGER_TYPE_UART=5 -DVM_DEBUGGER_TYPE_TEENSY=4 -DVM_DEBUGGER_TYPE_USB=3 -DVM_DEBUGGER_TYPE_FASTSERIAL=2 -DVM_DEBUGGER_TYPE_SOFTWARESERIAL=1 -DVM_DEBUGGER_TYPE_HARDWARESERIAL=0 -DVM_DEBUG_BANDWIDTH_THROTTLE_MS=100 -DVM_DEBUG_ENABLE=1 -DVM_DEBUG  -fpermissive -I"/External/StandardCplusplus"   -Dprintf=iprintf -w -x c++ -E -CC -mcpu=cortex-m3 -mthumb -DF_CPU=84000000L -DARDUINO=10804 -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -D__SAM3X8E__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x003e -DUSBCON -DUSB_MANUFACTURER="\"Arduino LLC\"" -DUSB_PRODUCT="\"Arduino Due\"" ystem/libsam" ystem/CMSIS/CMSIS/Include/" ystem/CMSIS/Device/ATMEL/" ores\arduino" ariants\arduino_due_x" ibraries\SPI\src" -I"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\Extensions\53ggn0bh.0i3\Micro Platforms\default\debuggers\VM_DBG" \External\StandardCplusplus\associative_base.cpp" -o "nul"
  
Back to top
 
IP Logged
 
RonOhmer
Junior Member
**
Offline


Posts: 29
Joined: Feb 10th, 2015
Re: Include directory in shared library project
Reply #9 - Sep 27th, 2017 at 4:00pm
Print Post  
AH-HA

This was all a big rabbit hole.  I have found the issue actually.  Standard C++ library has a bunch of header files that dont have an extension, therefore VisualMicro doesnt copy them over to the directory before building.

So, is it possible to tell VM to copy those files?  I have them "Included" in project, and changed them to be seen as "Header" files, but they still dont copy.

I suppose I could change them all to .h and edit the includes, but that isnt a very elegant solution.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Include directory in shared library project
Reply #10 - Sep 27th, 2017 at 4:09pm
Print Post  
Ah. Okay I will copy them over but ignore them during compile. Try to make a release over the next few days
  
Back to top
WWW  
IP Logged
 
RonOhmer
Junior Member
**
Offline


Posts: 29
Joined: Feb 10th, 2015
Re: Include directory in shared library project
Reply #11 - Sep 27th, 2017 at 4:26pm
Print Post  
Sweet thanks.
  
Back to top
 
IP Logged
 
RonOhmer
Junior Member
**
Offline


Posts: 29
Joined: Feb 10th, 2015
Re: Include directory in shared library project
Reply #12 - Sep 27th, 2017 at 4:37pm
Print Post  
Honestly Ive never written a VS plugin (Gave it some thought when I worked at Microsoft, then just asked the DevDiv guys for the ask).

But this is how I would expect the flow to be on my end:
Simple work flow:
1. If it is included in the project, copy it
2. If it is included and a cpp/c compile it

I am sure I left out 1000 nuances, but you get the idea.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint