"File can not be opened" compiler error in MPLABX /MPLAB IDE - microcontroller

I'm a newbie trying to lean PIC, I downloaded MPLAB and MPLAB X IDE. I have done this around 100 times and looked over web enough before asking this question, but my code does not compile and it always fails.
Here is what I did:
Created a new project using the project wizard,
Edited the code,
Copied the 16F871.H library header in both folder (I created the project in) and added it to the header files in MPLAB IDE.
Here's my code:
// IFIN.C Tests an input
#include " 16F877A.h "
void main()
{
int x; // Declare variable
output_D(0); // Clear all outputs
while(1) //
{
x = input(PIN_C0); // Get input state
if(x = = 1)
output_high(PIN_D0); // Change output
}
}
But on compiling the code, I'm getting the following error:
Executing:
"C:\Program Files\PICC\Ccsc.exe" +FM "NEW.c" #__DEBUG=1 +ICD +DF +LN
+T +A +M +Z +Y=9 +EA #__16F877A=TRUE
*** Error 18 "NEW.c" Line 2(10,23): File can not be opened
Not in project "C:\Users\jatin\Desktop\DHAKKAN PIC\ 16F877A.h "
Not in "C:\Program Files\PICC\devices\ 16F877A.h "
Not in "C:\Program Files\PICC\drivers\ 16F877A.h "
*** Error 128 "NEW.c" Line 2(10,17): A #DEVICE required before this line
*** Error 12 "NEW.c" Line 6(9,10): Undefined identifier -- output_D
*** Error 12 "NEW.c" Line 9(10,11): Undefined identifier -- input
*** Error 51 "NEW.c" Line 10(8,9): A numeric expression must appear here
5 Errors, 0 Warnings. Build Failed. Halting build on first failure as requested.
BUILD FAILED: Mon Jul 08 15:09:17 2013
I would be grateful if you could help me.

The error with respect to the header file not being found is that you have extra space in the header name. In other words, this:
#include " 16F877A.h "
should be:
#include "16F877A.h"
The other errors are probably a result of this and would go away once the header is properly included.
Note that the compiler literally takes the string inside "" or <> as file name for the header file and doesn't trim whitespaces for you.

Related

Getting Curl "Unsupported protocol" error

So i am trying to build a project with gcc and it emits the following compile failure
/home/cha/sdk-folder/sdk-source/avs-device-sdk/AVSCommon/Utils/src/LibcurlUtils/CurlEasyHandleWrapper.cpp:247:26: error: ‘CURLOPT_HTTPPOST’ is deprecated: since 7.56.0. Use CURLOPT_MIMEPOST [-Werror=deprecated-declarations]
247 | ret = setopt(CURLOPT_HTTPPOST, m_post);
| ^~~~~~~~~~~~~~~~
In file included from /home/cha/sdk-folder/sdk-source/avs-device-sdk/AVSCommon/Utils/include/AVSCommon/Utils/LibcurlUtils/CurlEasyHandleWrapper.h:20,
from /home/cha/sdk-folder/sdk-source/avs-device-sdk/AVSCommon/Utils/src/LibcurlUtils/CurlEasyHandleWrapper.cpp:20:
/usr/include/curl/curl.h:1195:3: note: declared here
1195 | CURLOPTDEPRECATED(CURLOPT_HTTPPOST, CURLOPTTYPE_OBJECTPOINT, 24,
| ^~~~~~~~~~~~~~~~~
/home/cha/sdk-folder/sdk-source/avs-device-sdk/AVSCommon/Utils/src/LibcurlUtils/CurlEasyHandleWrapper.cpp: In member function ‘void alexaClientSDK::avsCommon::utils::libcurlUtils::CurlEasyHandleWrapper::cleanupResources()’:
/home/cha/sdk-folder/sdk-source/avs-device-sdk/AVSCommon/Utils/src/LibcurlUtils/CurlEasyHandleWrapper.cpp:302:22: error: ‘void curl_formfree(curl_httppost*)’ is deprecated: since 7.56.0. Use curl_mime_free() [-Werror=deprecated-declarations]
302 | curl_formfree(m_post);
| ~~~~~~~~~~~~~^~~~~~~~
/usr/include/curl/curl.h:2606:1: note: declared here
2606 | curl_formfree(struct curl_httppost *form);
| ^~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[3]: *** [AVSCommon/CMakeFiles/AVSCommon.dir/build.make:734: AVSCommon/CMakeFiles/AVSCommon.dir/Utils/src/LibcurlUtils/CurlEasyHandleWrapper.cpp.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:11124: AVSCommon/CMakeFiles/AVSCommon.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:18943: SampleApplications/ConsoleSampleApplication/src/CMakeFiles/SampleApp.dir/rule] Error 2
make: *** [Makefile:5093: SampleApp] Error 2
basically the project is using deprecated API's . While trying to upgrade it to use the new API i am encountering a weird behaviour where the execution of that line fails and the curl error message that i am receiving is Unsupported protocol
auto result = curl_easy_setopt(handle, option, value);
Please note that value of option and value are CURLOPT_HTTP_VERSION and CURL_HTTP_VERSION_2_0
but if i add the following curl code above the above mentioned code snippet as shown below than everything starts to work magically
FILE *filep = fopen("~/dump.txt", "wb");
if(handle) {
curl_easy_setopt(handle, CURLOPT_STDERR, filep);
}
auto result = curl_easy_setopt(handle, option, value);
it seems like curl_easy_setopt(handle, CURLOPT_STDERR, filep);
must happen before curl_easy_setopt(handle, option, value)otherwise i get the unsupported protocol error. Can someone more experienced than me knows why that is happening or what i might be missing here.
Please note that initially i thought that the program is succeeding maybe due to some timing issue therefore i also tried putting some delay above auto result = curl_easy_setopt(handle, option, value); but still saw the same error message.

Using ArrayFire and Boost Compute in single code

I am trying to run a code which uses functions from both boost compute library and arrayfire library. I am getting the following errors when I try to build the code:
Scanning dependencies of target hello
[ 50%] Building CXX object CMakeFiles/hello.dir/hello.cpp.o
In file included from /opt/arrayfire/include/CL/cl.h:32,
from /usr/include/boost/compute/cl.hpp:19,
from /usr/include/boost/compute/system.hpp:20,
from /usr/include/boost/compute/algorithm/accumulate.hpp:17,
from /usr/include/boost/compute/algorithm.hpp:18,
from /usr/include/boost/compute.hpp:14,
from /home/rcms/debruijn/arrayfire/hello.cpp:2:
/opt/arrayfire/include/CL/cl_version.h:34:104: note: #pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 220 (OpenCL 2.2)
34 | #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 220 (OpenCL 2.2)")
| ^
[100%] Linking CXX executable hello
/usr/bin/ld: CMakeFiles/hello.dir/hello.cpp.o: undefined reference to symbol 'clGetDeviceIDs##OPENCL_1.0'
/usr/bin/ld: /opt/arrayfire/lib64/libOpenCL.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/hello.dir/build.make:85: hello] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/hello.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
The code I am using is a very simple helloworld using functions from both libraries.
#include <iostream>
#include <boost/compute.hpp>
#include <arrayfire.h>
namespace compute = boost::compute;
using namespace af;
int main()
{
// Boost Compute Part
// get the default device
compute::device device = compute::system::default_device();
// print the device's name and platform
std::cout << "hello from " << device.name();
std::cout << " (platform: " << device.platform().name() << ")" << std::endl;
// Array Fire Part
std::cout<< "ArrayFire Part:" << std::endl;
af::setDevice(0);
af::info();
return 0;
}
The CMakeList used to build the project is:
cmake_minimum_required(VERSION 3.0)
project(deBruijn_Graph)
find_package(ArrayFire)
add_executable(hello hello.cpp)
target_link_libraries(hello ArrayFire::afopencl)
I do not have a programming background. Please guide me on what I am doing wrong. How can I link these two libraries together in a single code?
Regards,
Hassan

posix_fallocate() failed: Operation not permitted while opening .realm file

I get the below error when i try to open and download .realm file in /tmp directory of serverless framework.
{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: posix_fallocate() failed: Operation not permitted" }
Below is the code:
let realm = new Realm({path: '/tmp/custom.realm', schema: [schema1, schema2]});
realm.write(() => {
console.log('completed==');
});
EDIT: this might soon be finally fixed in Realm-Core: see issue 4957.
In case you'll run into this problem elsewhere, here's a workaround.
This caused by AWS Lambda not supporting the fallocate and fallocate64 system calls. Instead of returning the correct error code in this case, which would be EINVAL for not supported on this file system, Amazon has blocked the system call so that it returns EPERM. Realm-Core has code that handles EINVAL return value correctly but will be bewildered by the unexpected EPERM returned from the system call.
The solution is to add a small shared library as a layer to the lambda: compile the following C file on Linux machine or inside lambda-ci Docker image:
#include <errno.h>
#include <fcntl.h>
int posix_fallocate(int __fd, off_t __offset, off_t __len) {
return EINVAL;
}
int posix_fallocate64(int __fd, off_t __offset, off_t __len) {
return EINVAL;
}
Now, compile this to a shared object with something like
gcc -shared fix.c -o fix.so
Then add it to a root of a ZIP file:
zip layer.zip fix.so
Create a new lambda layer from this zip
Add the lambda layer to your lambda function
Finally make the shared object be loaded by configuring the environment value LD_PRELOAD with value /opt/fix.so to your Lambda.
Enjoy.

Compiling Qt 5.3.0 for static linking under windows

I am trying to compile Qt for static linking following this tutorial: http://qt-project.org/wiki/How-to-build-a-static-Qt-for-Windows-MinGW
But i receive tons of warnings and a few errors.
For example this one:
C:/Developement/Qt/Tools/mingw482_32/bin/../lib/gcc/i686-w64-mingw32/4.8.2/../../../../i686-w64-mingw32/bin/ld.exe: cannot find -lqjp2
collect2.exe: error: ld returned 1 exit status
Makefile.Release:79: recipe for target '..\..\bin\dumpdoc.exe' failed
mingw32-make[4]: *** [..\..\bin\dumpdoc.exe] Error 1
mingw32-make[4]: Target 'first' not remade because of errors.
mingw32-make[4]: Leaving directory 'C:/Developement/Qt/Static/src/qt-everywhere-opensource-src-5.3.0/qtactiveqt/tools/dumpdoc'
Makefile:34: recipe for target 'release' failed
mingw32-make[3]: *** [release] Error 2
mingw32-make[3]: Target 'first' not remade because of errors.
for this, i set the environement variable to my path:
Name: LIBRARY_PATH
Value: C:\Developement\Qt\5.3\mingw482_32\bin
... but dunno yet if its gonna workin'
Beside this, i put the following paths to the PATH environement variable:
C:\Developement\Qt\5.3\mingw482_32\bin;
C:\Developement\Qt\Tools\mingw482_32\bin;
I am receiving tons of these kind of warning:
In file included from
C:\Developement\Qt\Static\src\qt-everywhere-opensource-src-5.3.0\qtbase\src\3rdparty\libjpeg/jpeglib.h:25:0,
from ......\3rdparty\jasper\src\libjasper\jpg\jpg_jpeglib.h:74,
from ......\3rdparty\jasper\src\libjasper\jpg\jpg_dec.c:75:
C:\Developement\Qt\Static\src\qt-everywhere-opensource-src-5.3.0\qtbase\src\3rdparty\libjpeg/jconfig.h:55:0:
warning: "HAVE_STDDEF_H" redefined [enabled by default] #define
HAVE_STDDEF_H ^ In file included from
......\3rdparty\jasper\src\libjasper\include/jasper/jas_tvp.h:75:0,
from ......\3rdparty\jasper\src\libjasper\jpg\jpg_dec.c:70:
......\3rdparty\jasper\src\libjasper\include/jasper/jas_config.h:65:0:
note: this is the location of the previous definition #define
HAVE_STDDEF_H 1 ^ In file included from
C:\Developement\Qt\Static\src\qt-everywhere-opensource-src-5.3.0\qtbase\src\3rdparty\libjpeg/jpeglib.h:25:0,
from ......\3rdparty\jasper\src\libjasper\jpg\jpg_jpeglib.h:74,
from ......\3rdparty\jasper\src\libjasper\jpg\jpg_dec.c:75:
C:\Developement\Qt\Static\src\qt-everywhere-opensource-src-5.3.0\qtbase\src\3rdparty\libjpeg/jconfig.h:59:0:
warning: "HAVE_STDLIB_H" redefined [enabled by default] #define
HAVE_STDLIB_H ^
In file included from ......\3rdparty\jasper\src\libjasper\include/jasper/jas_tvp.h:75:0,
from ......\3rdparty\jasper\src\libjasper\jpg\jpg_dec.c:70:
......\3rdparty\jasper\src\libjasper\include/jasper/jas_config.h:71:0:
note: this is the location of the previous definition
#define HAVE_STDLIB_H 1
^
......\3rdparty\jasper\src\libjasper\jpg\jpg_dec.c: In function 'jpg_decode':
......\3rdparty\jasper\src\libjasper\jpg\jpg_dec.c:134:49: warning: parameter 'optstr' set but not used
[-Wunused-but-set-parameter]
jas_image_t *jpg_decode(jas_stream_t *in, char *optstr)
^
......\3rdparty\jasper\src\libjasper\jpg\jpg_dec.c: In function 'jpg_start_output':
......\3rdparty\jasper\src\libjasper\jpg\jpg_dec.c:298:47: warning: parameter 'cinfo' set but not used
[-Wunused-but-set-parameter]
static void jpg_start_output(j_decompress_ptr cinfo, jpg_dest_t *dinfo)
^
......\3rdparty\jasper\src\libjasper\jpg\jpg_dec.c: In function 'jpg_finish_output':
......\3rdparty\jasper\src\libjasper\jpg\jpg_dec.c:335:48: warning: parameter 'cinfo' set but not used
[-Wunused-but-set-parameter]
static void jpg_finish_output(j_decompress_ptr cinfo, jpg_dest_t *dinfo)
^ ......\3rdparty\jasper\src\libjasper\jpg\jpg_dec.c:335:67: warning:
parameter 'dinfo' set but not used [-Wunused-but-set-parameter]
static void jpg_finish_output(j_decompress_ptr cinfo, jpg_dest_t *dinfo)
^
Wasn't i prepared enough to compile Qt?
What do i need to do in order to be able to compile Qt without getting errors everytime thrown out?
How long would it take until its compiled.

QFile::copy says "can't open source file for input"?

I'm going to copy one file using QFile::copy function but this function always returns false and errorString says :
"Cannot open D:/tmp/buf34.txt for input"
I tried to run this program with administrator privilege but nothing changed. My code is really simple :
QString source = url.toLocalFile();
QString destination = _dir.absolutePath()
+ QString("/%1").arg(QFileInfo(source).fileName());
qDebug()<<"Cp from :" << source << " to : "<< destination;
QFile file(source);
qDebug()<<file.copy(destination);
qDebug()<<file.errorString();
Edit:
I have QListView occupied with a QFileSystemModel. I try to drag one file from this ListView to a QLabel. For the QLabel a destination path is set. In drop event I try to copy file.
QFile::copy uses QFile::open but overwrites the error message open would give by the unhelpful "Cannot open %1 for input" you got.
So, you should try opening the file yourself to get that original error message:
qDebug()<<file.open(QFile::ReadOnly);
qDebug()<<file.errorString();

Resources