5 Replies Latest reply on Apr 10, 2017 3:12 AM by mlanesmith

    How to include files from external folder in System Studio

    JelleRoets

      I have developed a couple of libraries (.h + .cpp files) myself that I want to share between multiple projects. So I saved those files in a separate folder outside the project folder itself (let's say "libs"). Now I want to include files from that libs folder in my main project and compile and link them together.

       

      Previously (one year ago) I used the devkit eclipse environment and I was able to do so by taking the following steps:

      - right click my project folder > new folder >> advanced > "link to alternate location (linked folder)" : this adds a link to my libs folder in the current project

      - right click my project folder > Properties > C/C++ General > Paths and Symbols > Includes > Add... : this made sure my libs folder is added as an include directory (a -I [path to libs folder) flag is added to each compile instruction)

       

      However in the new intel System Studio environment the whole project is build inside a docker container. And the above approach doesn't work anymore: the -I flag is still added to the compile instruction however the path is a absolute path on my computer to that libs folder, which isn't available in the docker container, hence I get compile errors that included libraries are not found.

       

      How can I make this work again? In other words, how can I instruct which files to copy to the docker container before the compile commands are executed?

        • 1. Re: How to include files from external folder in System Studio
          Intel Corporation
          This message was posted on behalf of Intel Corporation

          Hi JelleRoets,

          Thank you for reaching out.
          Is it possible to share the code you’re using just to make some tests on my own? I haven’t tried this yet with the new Intel System Studio, however, my approach would have been the same that you used for previous Eclipse versions, so I guess I should get the same error if I try the same. I would like to confirm this behavior.

          Regards,
          -Pablo

          • 2. Re: How to include files from external folder in System Studio
            JelleRoets

            In the meantime I was able to solve this issue myself: trick was to find the correct in-docker-container link to my libs folder for the includes:

             

            So to include a linked folder to your project do:

            - right click project folder > new folder >> advanced > "link to alternate location (linked folder)" : this adds a link to my libs folder in the current project

            - right click project folder > Properties > C/C++ General > Paths and Symbols > Includes > Add... : fill out "//${DOCKER_IMAGE}${DOCKER_SYSROOT}/workspace/[folder_name]": this adds a -I include flag to each compile instruction but with the correct in-docker-container link to the folder.

             

            I figured this out by manually accessing the running docker container and investigate the folder structure: it seems that eclipse copies all files to compile in a folder called "workspace" in the system root folder of the docker container. I think it should be good to add this somewhere to the Intel System Studio documentation, since it cost me a lot of time to figure it out myself, and it is very hard to guess!

             

            See attached screenshot for a working example of my workspace

            Screen Shot 2016-12-27 at 16.40.55.png

            1 of 1 people found this helpful
            • 3. Re: How to include files from external folder in System Studio
              Intel Corporation
              This message was posted on behalf of Intel Corporation

              Hi Jelle,

              Thank you very much for your contribution, this will definitely help other users who want to do the same. We will pass your feedback about expanding the ISS documentation to include this information about Eclipse copying all files to compile in the “workspace” folder. This should be added.

              Regards,
              -Pablo

              • 4. Re: How to include files from external folder in System Studio
                Electrumpet

                Hi Jelle,

                 

                Thanks a ton for this. I have been stuck for ages as well and this is certainly not straight forward. I wonder how you ever found out. Anyway. I have my library not working yet but at least I can try to do an informed effort now since it finally seems to be recognised... It would be nice if there was some kind of tutorial on the use of external libraries on the Intel Edison in C as well. It is this kind of thing that turn people away from a platform if something so seemingly straight forward is handled in such a complicated way without proper documentation. We want to make things and not spend our time effortlessly looking for this kind of solutions... It would also be nice if this was added to Harry Fairheads Exploring Intel Edison book... I will suggest it to him...

                 

                Best, Hans.

                • 5. Re: How to include files from external folder in System Studio
                  mlanesmith

                  This solution didn't work for me. Maybe it's a host platform difference - I'm on a Mac.

                   

                  I linked the folders into the workspace as shown, but the compiler was given for source files the resolved path (outside the workspace) rather than the symlinked path inside. Worse, they were passed as relative paths (".../.../.../RoboticsCodebase/*"). No way to fake that out.

                   

                  -i includes were given as full resolved path ("/Users/martin/*").

                   

                  If I copied everything into the workspace, I could compile provided I hacked the include paths as described. This is not a solution I want to use and I've gone back to an older (non-Docker) dev kit. I don't know how I'm going to work with the Joule I've already bought!  

                   

                  Hard ln links would probably work OK but I'd have to set them up on a per file basis! I have dozens of affected source files.

                   

                  I understand why you've switched to using Docker, but having the compiler and Eclipse in non-matching filesystems is a major headache for other than simple cases. Basic Eclipse features such as Import simply don't work as expected.

                   

                  I'm sticking with last years model for now.