compiling source files in different directory - windows

I am trying to compile source files from one level up from folder where my source and makefile is present. following is the my directory structure and I have implemented source file..
Directory structure..
project \common\a.c
\platform\win\source
\makefile
Since my source file and make file, both are in win folder so I am trying to compile a.c from win folder
c:\project\platform\win\build -Cez
SOURCE FILE:
DIR=..\ ..\common
SOURCE= \
$(DIR)\a.c
I am getting error "Invalid directory". Can any body suggest me what I am doing wrong or give any clue.
Thanks

Related

PIC Header Files

I have trouble building my pic project. I used
#include "p18f8722.inc"
at the beginning of my .asm file but it gives the following error:
can't open include file "p18f8722.inc": No such file or directory
How can I deal with this issue?

Visual Studio does not find include files, but paths are correct

For my project, I am using Visual Studio 2015. I have added to my include path the folder $(ProjectDir)Source. In details view of Include Directories, in the list below with Evaluated value, the correct path is listed. When I copy this path using #include "path/file", it finds the file. Or via Start > Run, it opens the path.
In my project I have a .cpp file which includes the file like usual:
#include <file>.
Still, I am receiving the error: Cannot open include file 'file.h' No such file or directory. Error C1083.
I copied an existing solution which had similar includes and adjusted them accordingly. It works now.

Working directory vs output path in visual studio

What is the difference of the working directory vs the output path in visual studio?
Is it bad to set both setting to the same directory like '....\bin\'
By default they are the same. Assuming you're debugging some application it will be bin\debug.
Output Directory is where your output files goes. By default, Visual Studio builds each project in a solution in its own folder inside the solution. You can change the build output paths of your projects to force all outputs to be placed in the same folder
Working Directory is the location which Specifies the working directory of the program being debugged. It is the default place in which a program is looking up it's files. Normally the working directory is the directory the application is launched from \bin\debug by default.
So every opened file will be opened relative to the working folder.Let's say if you have an application installed in c:\myapp with all lib files in the same directory then you will set your working directory to myapp folder and you can do so from project properties.
By default, working directory is the output directory. Both can be changed, you can set another directory or common directory for all projects for output directory that determines a relative path for the output file that might be an executable or a static library.
Working directory also provides a relative path to put files that are used by the program. You can put a log file into a place that you can use its directory as a relative path in the code instead of absolute path. If your working directory is myproject\src and your log file is in myproject\src\log\log.txt then you can open or write the log file with log\log.txt in the code rather than c:\blabla\myproject\src\log\log.txt.

Where can i find the 16F877A.h?

When i run my program in MPLAB. ( Project wizard -> PIC16F877A -> Hi Tech Ansi C Compiler -> RUN )
Error [141] C:\Users\WhyWhy\Desktop\test.c; 1.22 can't open include file "16F877A.h": No such file or directory
Where can i find the header file for the 16F877A?
Chip-specific header files should not be explicitly included in HITECH-C, the documentation clearly states that. Instead, you include the compiler header, which will take care of including the chip-specific file for you:
#include <htc.h>
All you need for this to work is to configure correct chip in the project settings. The 16F877A.h file exists in the compiler directory, but including it directly will throw a warning.
C:\Program Files\HI-TECH Software\PICC\9.70\include
In my case , I have installed HITech Compiler In C:\ Program Files.
You have to know, where have you installed the files of the compiler.
This file is from the compiler, so in your case the Hi Tech you can find here:
C:\Program Files\HIā€TECH Software\PICC\\include\
Before you have found the file you have to add in the Header Files folder in the Project window on MPLAB.
And in your code you have to include it
#include <16F877A.h>

yacc and bison in visual studio

I am going to port the C project that was for unix into windows. So far, I could make it compile but not build . The problem I am getting is , some of the functions which are declared in the header files are defined in the yacc files.so I am getting the following errors:
error LNK2001: unresolved external symbol function_name
I am adding .y and .l files in the source directory of the project.I think I could not port yacc files into windows version or am I doing something stupid.I search it on web but could not get proper tutorial for it.Could you please let me know
How could I add .y or .l files in the project.
How would I make those file compatible to the windows?
How can I link them with other object files.
EDIT
I tried with changing the the .l files into the .yy.c files using the flex.exe.Following is the command for it
c:\> flex.exe name.l
Supposing that both the flex.exe and name.l are in C;>.And I loaded those all those files .l .y(previously present for parsing in unix system) .yy.c(corrsonding yacc file for windows) in the solution of previously exisiting project. Once I compile,I get the following
Can't read the header file parserheaderfile.h
This is the header file which needs to be generated by the bison in the unix
system. So I think I am not able to make the bison compatible for windows .So please him me how can I solve this problem?
Thanks in advance.
You need to add custom build rules for your .y and .l files. To do this, you need to
create one dummy .c file for the .l file and the .y file
add the .l, .y and both .c files to the project
right click on the .l file and select properties
Configuration->All Configurations
General->Item Type->Custom Build Tool
Apply
Custom Build Tool->General->Command Line->flex -olexer.c lexer.l
Custom Build Tool->General->Outputs->lexer.c
Custom Build Tool->General->Additional Dependencies->parser.y parser.c
Apply
select the .y file in the solution explorer
Configuration->All Configurations
General->Item Type->Custom Build Tool
Apply
Custom Build Tool->General->Command Line->bison -oparser.c parser.y
Custom Build Tool->General->Outputs->parser.c parser.h
Also you need to have flex.exe, bison.exe and m4.exe in the system search path. Another drawback is that VS does not get the dependencies right, so when you change something in the parser or lexer files, you need to manually rebuild the project.

Resources