What is the minimal set of files after creating a project in Visual Studio (2010) that You have to send to somebody who uses a different compiler ? (for example the Debug folder isn't necessary, but what about .vcxproj.user file or other ?)
What are .obj files?
What kind of information is displayed in "watch" and "call stack" windows during debugging ?
The only files you absolutely need to send someone are the source files and the project file. The source files will usually be *.c or *.h files, but could include others, like resources.
As far as the other files go, each of them does something slightly different. The full list, as of VS2013, is found here. Most of them are generated by compiling and linking, or by opening the project in the IDE. A quick way to tell them apart is to do a Clean Solution, which should delete and intermediate files.
The obj files are intermediate files use during linking, and don't need to be packaged. In fact, nothing in the build or output folders needs to be included, as they'll all get rebuilt. The information that's used at debugging is mostly pulled from the obj and pdb files, which are both created each time you build.
Related
I have successfully compiled (azure_iot_sdk_c) on Linux and successfully run this demo (iothub_ll_c2d_sample). Now, I want to extract the source code related to this demo to facilitate the migration to the embedded Linux platform. What should I do? The source code provided by Microsoft contains a lot of code unrelated to the Linux platform in order to be compatible with more platforms.
I tried to take out the source code in the sdk, delete the code of other platforms, and judge whether the platform is related by the file name, but it could not be compiled. I want to know what files are required for this demo (iothub_ll_c2d_sample) to run normally. I want to take them out and compile them separately, so that they can be ported to the embedded Linux platform.
You can extract the code sample file and compile it independently by importing the required header files for the code in iothub_ll_c2d_sample.c
Even though the code lists only six external reference files, some of the header files have internal dependencies. By back tracing, I found eighteen header files that are referenced by them. You would have to provide a local reference to all these files to make the code compile successfully. Please find the below image referring all the header files the program needs to compile.
You can get the header files from the below URLs
https://github.com/Azure/azure-c-shared-utility/blob/master/inc/azure_c_shared_utility/map.h
https://github.com/Azure/azure-iot-arduino-utility/blob/master/src/azure_c_shared_utility/azure_macro_utils/macro_utils.h
https://github.com/Azure/azure-iot-sdk-c/blob/main/iothub_client/inc/iothub_device_client_ll.h
https://github.com/Azure/azure-iot-arduino-utility/blob/master/src/azure_c_shared_utility/azure_macro_utils/macro_utils_generated.h
https://github.com/Azure/azure-iot-sdk-c/blob/main/iothub_client/inc/iothub.h
https://github.com/Azure/azure-iot-sdk-c/blob/main/iothub_client/inc/iothub_transport_ll.h
https://github.com/Azure/azure-iot-sdk-c/blob/main/iothub_client/inc/iothub_client_core_ll.h
https://github.com/Azure/azure-iot-sdk-c/blob/main/iothub_client/inc/iothub_client_core_common.h
https://github.com/Azure/azure-iot-sdk-c/blob/main/iothub_client/inc/iothub_message.h
https://github.com/Azure/azure-c-shared-utility/blob/master/inc/azure_c_shared_utility/strings.h
https://github.com/Azure/azure-c-shared-utility/blob/master/inc/azure_c_shared_utility/const_defines.h
https://github.com/Azure/azure-c-shared-utility/blob/master/inc/azure_c_shared_utility/strings_types.h
https://github.com/Azure/azure-iot-sdk-c/blob/main/iothub_client/inc/iothubtransportmqtt.h
https://github.com/Azure/azure-c-shared-utility/blob/master/inc/azure_c_shared_utility/shared_util_options.h
https://github.com/Azure/azure-c-shared-utility/blob/master/inc/azure_c_shared_utility/crt_abstractions.h
https://github.com/Azure/azure-c-shared-utility/blob/master/inc/azure_c_shared_utility/threadapi.h
https://github.com/Azure/umock-c/blob/master/inc/umock_c/umock_c_prod.h
https://github.com/Azure/azure-iot-sdk-c/blob/main/iothub_client/inc/iothub_client_options.h
Note that since I have the files under the same directory, I will no longer need to provide a relative path while referencing the header files in the program. I can directly access them as below
The same goes with the header files. I can directly refer the dependent header files without providing any relative path. Please find the below image of the iothub.h header file which refernces umock_c_prod.h file and notice there is no relative path.
If you decide to place the header files under a different directory, make sure to provide a relative path for the code to compile.
I want to run a C project on Compiler Explorer (godbolt.org) which includes some external header files. What is the procedure to include these third-party header files on there?
Screenshot of the project
Suppose I want to run this code which includes snipmath.h file. Also, snipmath.h header includes other lib files. How can I include all of them in godbolt? like we usually do in a offline compiler.
Remarkably, only 1 week before you posted the question this feature was added to compiler explorer. As of Nov 2021 it is reported to still have some rough edges, and not every combination of controls work - but starting from the simple template Matt delivered and following his instructions work for me:
go to compiler explorer
click "Add..." at the very top left and choose "Tree (IDE mode)".
Move the files you have open into "Included files" with the plus (you will have to give them names)
(For C++) tick "CMake" and then create a CMakeLists.txt with appropriate info it in
Ensure it says -DCMAKE_BUILD_TYPE=Debug in the box under
In the box under that choose the name of your target, e.g. "test"
You can then "Add new..." and make a compiler that will run CMake
Note this does not include uploading the headers, but rather pasting them in new CE editors. Also, judging by your screenshot - when you write 'other lib files' I assume you mean other headers. Lib files aren't supported.
If your project was a CMake one, you might have been able to upload it directly (someone did).
You can use Compiler Explorer with Cmake and have multiple header and source files. You could even have some other files to read from (like *.ini). Try it here reading *.ini in Compiler Explorer
Note: the examples are with C++, but it must be straightforward to do it with C.
I am using Visual Studio (2017) and I need the following.
I have a folder where a code generator puts the .h and .c files obtained from a formal model. This folder is not controlled by me, e.g. I cannot write in it, but it is updated by another team member.
By using the /I compiler options (or Additional include directories in the project properties) I managed to import all the generated header files in my VS project. What I am supposed to do is to integrate this generated code into a specific platform, this means that I have to compile both the generated code and the integration code on the target platform. The problem is, the compiler is not able to resolve the generated function definitions of the generated code as it only sees the .h files. What I got is a linking error (external symbol not resolved)
To solve the problem, I added the existing .c files manually, one by one. The obvious problems that comes with this solution are
manual boring work
when new files are generated, I need to manually import the new files
Question is: is there an option that can be set in order to specify the path of the source files without passing them one by one?
note: just copying and pasting the generated code in the VS project folder is not an acceptable solution.
Thanks
If you look at https://learn.microsoft.com/en-us/cpp/ide/working-with-project-properties?view=vs-2017 then you see there is a Source Directories property that has $(VC_SourcePath) as a default but (I think) to which you can add additional paths. The documentation is unclear whether that means all source files in such a path will be included for compilation.
At the bottom of the documentation it explains how to override certain project properties by providing an external properties file. It seems you can override the targets/sources using such a file. You can generate the file using a small tool that reads the filenames in those directories and adds them to the file.
You could also analyze the .vcproj file and build a small tool that wil re-write the part with your generated source directories, reading the filenames in those directories and adding them to the section in the .vcproj file.
I have mostly used kate, vim etc to code and just pure console and gdb (rarely) to test. I want to start using eclipse, mainly for ease of looking up stuff, and hopefully (while not super important,) run the GUI debugger.
However, I don't want eclipse to touch my real project folders (it should change the code, obviously, but don't want it to create any configuration folders etc). Is that possible? I was thinking to create a workspace on a different folder, and add sources from my project path. But this seem to be complicated without any experience with eclipse when handling Makefiles etc!
Anyone has done something similar? any guidelines?
Yes, this is fairly straightforward. Instead of creating a standard C Project that creates and manages makefiles for you, use the "Makefile Project with Existing Code" instead.
If you don't want the .cproject, .project, etc files intermixed, create the CDT project in an empty directory and use Linked Files and Folders to pull in what you do want in the project.
If you do try to do a Build within Eclipse it will do "make all", but if you don't have a Makefile you get this (same for clean):
make all
make: *** No rule to make target `all'. Stop.
What I have done is for projects that don't have a make equivalent (like CPython extension) is to write a trivial Makefile that delegates all and clean targets to my real tool.
Once you have the project created, you will need to configure it to get all the goodness of CDT. The CDT Indexer and Scanner needs to know about your compiler settings (includes and defines really). There are two ways of delivering that information:
Run a verbose build (i.e. with gcc command line arguments echoed) from within Eclipse (e.g. use trivial Makefile described above). CDT will parse that output and automatically pick up compiler options used.
There are a number of ways that CDT can learn about what your settings are, to configure how they are picked up, head to project properties -> C/C++ General -> Preprocessor Include Paths, Macros etc. and adjust the sources in the Providers tab:
In the project properties, edit the C/C++ General -> Paths and Symbols properties. You may have to do this if CDT cannot determine all your settings in Step 1 too. This is a screenshot of some of those settings:
I'm doing some Linux kernel development, and I'm trying to use Netbeans. Despite declared support for Make-based C projects, I cannot create a fully functional Netbeans project. This is despite compiling having Netbeans analyze a kernel binary that was compiled with full debugging information. Problems include:
files are wrongly excluded: Some files are incorrectly greyed out in the project, which means Netbeans does not believe they should be included in the project, when in fact they are compiled into the kernel. The main problem is that Netbeans will miss any definitions that exist in these files, such as data structures and functions, but also miss macro definitions.
cannot find definitions: Pretty self-explanatory - often times, Netbeans cannot find the definition of something. This is partly a result of the above problem.
can't find header files: self-explanatory
I'm wondering if anyone has had success with setting up Netbeans for Linux kernel development, and if so, what settings they used. Ultimately, I'm looking for Netbeans to be able to either parse the Makefile (preferred) or extract the debug information from the binary (less desirable, since this can significantly slow down compilation), and automatically determine which files are actually compiled and which macros are actually defined. Then, based on this, I would like to be able to find the definitions of any data structure, variable, function, etc. and have complete auto-completion.
Let me preface this question with some points:
I'm not interested in solutions involving Vim/Emacs. I know some people like them, but I'm not one of them.
As the title suggest, I would be also happy to know how to set-up Eclipse to do what I need
While I would prefer perfect coverage, something that only misses one in a million definitions is obviously fine
SO's useful "Related Questions" feature has informed me that the following question is related: https://stackoverflow.com/questions/149321/what-ide-would-be-good-for-linux-kernel-driver-development. Upon reading it, the question is more of a comparison between IDE's, whereas I'm looking for how to set-up a particular IDE. Even so, the user Wade Mealing seems to have some expertise in working with Eclipse on this kind of development, so I would certainly appreciate his (and of course all of your) answers.
Cheers
Eclipse seems to be pretty popular for Linux kernel development:
http://cdtdoug.blogspot.com/2008/12/linux-kernel-debugging-with-cdt.html
http://jakob.engbloms.se/archives/338
http://revver.com/video/606464/debugging-the-linux-kernel-using-eclipsecdt-and-qemu/
I previously wrote up an answer. Now I come up with all the details of the solution and would like to share it. Unfortunately stackoverflow does not allow me to edit the previous answer. So I write it up in this new answer.
It involves a few steps.
[1] The first step is to modify linux scripts to leave dep files in. By default after using them in the build, those dep files are removed. Those dep files contains exact dependency information about which other files a C file depends. We need them to create a list of all the files involved in a build. Thus, modify files under linux-x.y.z/scripts to make them not to remove the dep files like this:
linux-3.1.2/scripts
Kbuild.include: echo do_not_rm1 rm -f $(depfile);
Makefile.build: echo do_not_rm2 rm -f $(depfile);
The other steps are detailed in my github code project file https://github.com/minghuascode/Nbk/blob/master/note-nbkparse. Roughly you do:
[2] Configure with your method of configuration, but be sure use "O=" option to build the obj files into a separate directory.
[3] Then use the same "O=" option and "V=1" option to build linux, and save make output into a file.
[4] Run my nbkparse script from the above github project. It does:
[4.1] Read in the make log file, and the dep files. Generate a mirroring command.
[4.2] Run the mirroring command to hard-link the relevant source files into a separate tree, and generate a make-log file for NetBeans to use.
Now create a NetBeans C project using the mirrored source tree and the generated log file. NetBeans should be able to resolve all the kernel symbols. And you will only see the files involved in the build.
The Eclipse wiki has a page about this: HowTo use the CDT to navigate Linux kernel source
I have been doing some embedded linux development. Including kernel module development and have imported the entire linux kernel source code into Eclipse, as a separate project. I have been building the kernel itself outside of Eclipse(so far), but I don't any reason why I shouldn't be able to set up the build environment within Eclipse to build the kernel. For my projects, as long as I setup the PATH properties to point to the appropriate linux source include directories, it seems to be pretty good about name completion for struct fields, etc.
I can't really comment, on if it is picking up the correct defines and not greying out the correspond sections, as I haven't really paid to much attention to the files within the kernel itself.(so far)
I was also wondering about using Netbeans as a linux 'C' IDE, as I do prefer Netbean's for Java GUI development.
I think this would work (done each step for various projects):
[1] Modify kernel build scripts to leave .d files. By default they are removed.
[2] Log the build process to a file.
[3] Write a script to parse the build log.
[3.1] From the build log, you know every .c files.
[3.2] From the .c file, you know which is the corresponding .d file.
[3.3] Look into .d files to find out all the included .h files.
[3.4] Form a complete .c and .h file list.
[4] Now create a new dir, and use "ln -s" or "ln" to pick files of interest.
Now, create a Netbeans project for existing source code in the [4].
Configure code assistance to use make-log file. You should see
exactly the effective source code as when you build it at [2].
Some explanations to the above steps:
At [2], do a real build so the log file contains the exact files and flags of interest.
Later netbeans will be able to use the exact flags to parse.
At [4], pick only the files you want to see. Incorporating the whole kernel tree into netbeans will be unpractical.
There is a trick to parsing .d files: Many of the depended items are not real paths to a .h file, they are a modified entry for part of the linux config sections in the auto config file. You may need to reverse the modification to figure out which is the real header file.
Actually there is a topic on netbeans site. This is the discussion url: http://forums.netbeans.org/ntopic3075.html . And there is a wiki page linked from the discussion: wiki.netbeans.org/CNDLinuxKernel . Basically it asks you to prefix make with CFLAGS="-g3 -gdwarf-2" .
I found this link very helpful in setting up proper indexing in Eclipse. It requires running a script to alter Eclipse environment to match your kernel options, in my case
$ autoconf-to-eclipse.py ./include/generated/autoconf.h .
An illustrated guide to indexing the linux kernel in eclipse