How to fix "ReferenceError: Can't find variable: $jscomp" (phantomjs) or "ReferenceError: $jscomp is not defined" (firefox, chromium)? - angularjs

After compiling javascript code with closure compiler (v20190729.0.0, previous versions too), I get ReferenceError: Can't find variable: $jscomp.
Is there a solution that does not require to turn polyfills off with the option --rewrite_polyfills=false?

If I follow, it's a bit confusing which compilation_level you are using, based on your comments;
If you're using WHITESPACE_ONLY it might be that you're expecting Closure to do more than its doing (bundling). "The output JavaScript is functionally identical to the source JavaScript." so if you're adding deps.js in dev, and then compiling with closure, you'll still need deps.js.

Related

Redefinition + Conflicting types errors, but nothing is being redefined or actually conflicting

I am getting some errors I'm not really understanding, nor a solution to get around them.
I am working on a ESP32 Bluetooth connection using esp-IDF, VSCode, and PlatformIO.
I have a section of code
esp_hid_gap_init(ESP_BT_MODE_BTDM);
esp_ble_gattc_register_callback(esp_hidh_gattc_event_handler);
esp_hidh_config_t config = {
.callback = hidh_callback,
};
ESP_ERROR_CHECK( esp_hidh_init(&config) );
btkeyboard_queue_init();
ESP_ERROR_CHECK( err );
That is initialising Bluetooth and looking for connections, it requires the use of a header called bluetoothkeyboard.h which i pulled from: https://github.com/bozont/Duke3D/tree/master/components/SDL/bluetoothkeyboard
When i include this header in my main.c i get 11 errors, 10 from bluetoothkeyboard.h and one from SDL_event.h (also in the github repo i linked) they are:
The code is all unmodified and it clearly works in his demo and many others who have used it and I'm not keen on messing with a third-party library, I just don't understand what's going on and how to move around it.
Earlier it was compiling but I was getting a Collect2.exe: error: ld returned 1 exit status. To get around it I tried moving the section above into my main.c just to check but ended up in this world of pain.
I get the messages are telling me I am redefining a function, but you use the right click find all and it just references itself so I'm at a loss.
EDIT
Here is an example of one of the compiler errors:
And my CMAKE file
cmake_minimum_required(VERSION 3.16.0)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(TTGODemo)
EDIT2**
Ok so taking the comments on board, I removed the second include of BTKeyboard out of the ESP_HID_GAP.H i had. I had put it in there to cover a static constant char that was declared in only bluetoothkeyboard.h so idk how they were communicating.
That was done, I got the following wall of Text:
I think there are functions in the Bluetooth libraries that are also in the esp_hid_gap.h that it's getting hung up on. But i don't really know what to do about it, i could try removing the BT libraries but that will probably make things worse.
Thoughts?

absolute path in static compiled library removing

sorry I know it is repeated and it is similar to this question but there was only one answer which doesn't satisfy the objective :)
The compilation of uamqp library is pretty easy. I end up with 2 static libraries to be used when linking in my project in eclipse. During run time and if an error happens, the error message shows the path, where the static libraries are originally compiled. I get something like this:
Error: Time:Tue May 22 09:04:45 2018 File:/home/hostname/azure-uamqp-c/src/saslclientio.c Func:on_underlying_io_error Line:243 Error callback received in unexpected state
I have no problem with the error message. The issue is only when the error occurs, then it shows the path /home/hostname/azure-uamqp-c/saslclientio.c
Please how can I compile the uamqp library, so that no absolute paths are stored inside? is it a cmake command option that I do have to configure?
Thanks
Message "Error callback received in unexpected state" is emitted by LogError() call, and LogError macro eventually uses preprocessor expression __FILE__ for refer to the path of source file.
According to that answer, expression __FILE__ is expanded to path, which is passed in compiler's command line.
Unfortunately, CMake always uses absolute paths for source files when pass them to the compiler. So there is no easy way for generate relative paths in logs.
You may write a wrapper around compiler, which transforms absolute paths to relative and calls compiler.

grunt-contrib-jasmine angularjs module-not-available error

I have a script that looks like this:
angular.module('Game').constant('WHITE_PIECE', '\u26C0')
... more lines ...
.constant('WHITE_KING', '\u26C1')
(end of file)
When I run grunt jasmine, I get the classic error, Module 'Game' is not available! You either misspelled.... Oddly though, I'm positive that module is being declared. If I move the code to the end of the file where the 'Game' module is declared, it works. If I move the code to the end of a different file, which declares a service for the 'Game' module, it works. I get no errors in my browser. Is this phantomjs being dumb? Is it a bug in Grunt-contrib-jasmine?
I put console.log statements before this file and before the file which declares the Game module; this showed that the constants file is being interpreted before the Game file. However, I thought Angular was clever enough to figure that out. Do I need to tell grunt-jasmine-contrib exactly which order to load my scripts?
Based on more Googling, I believe this to be a bug and not a mistake. The only solution is to force the correct order of script interpretation, which unfortunately negates the convenience of the jasmine globstar source pattern (e.g. **/*.js).

"First defined here" error in Eclipse with C

I'm trying to compile a C program using libxml2 in Eclipse. It seems like my code doesn't have problems, but there are errors when I build my project.
The error output is in this screenshot: https://drive.google.com/file/d/0BwV-0_2diIaaQlZHM2Fwa2R0LWc/edit
Before this error, I had an “Undefined reference to” error, but it was because I forgot to link the library libxml2. Now it's the problem in the screenshot. I don't what to do.
[EDITED]
I solved my problem I just need to put -nostartfiles in the linker flags.
I solved my problem I just need to write -nostartfiles in the Linker Flags box :D
To find "Linker Flags" box go to Your Project > Properties > C/C++Build > Settings > GCC C Linker > Miscellaneous
That's it.
Thanks for help.
I don't think your solution is acceptable, I think it will lead to the same problem when your project is executed in other environment (another eclipse configuration, running it from console, etc)
That error occurs when you have defined the same function more than one time in your project, and I bet it's because you have defined the same function you already had in a library.
For example, if I have lib1.h with a function called hello() and then write the same function in your main.c (having that library linked) that problem will occur.
In fact, in your image, I can see "multiple definition of __data_start"
So I think you just have to change the problematic function name and it will be fixed.
In addition, this problem will be caused if you include the same library more than once in your program, but it can be solved using preprocessor (if you are interested in this, google it, since it would be off-topic and make my answer too long)

Syntastic C make checker not reporting errors

I'm writing C code and was initially using the gcc checker. Errors were reported in the C file. Lots of errors that didn't matter were being reported due to, for instance, no include directory switches on the gcc command line in the checker. Because we're using icc and it feels unwieldy to setup all of the parameters that are already setup in our makefile, I decided to switch over to using the make checker.
Upon switching to the make checker, I did not get any results. Looking at the makeprg command in make.vim, it is make -sk. I realized that our makefile was not setup to do syntax checking, so I created a new target called syntax_check that added the -fsyntax-only and -c flags. I then changed the make.vim makeprg command to make -sk clean syntax-check so that the appropriate target is run.
When I save the file I watched top in another window and saw that the build is occuring. However, I'm still getting no errors. By this, I mean I don't see the green sidebar indicating lines that did not have errors. Running :Errors does not bring up the location list.
Any ideas? And is my understanding of how to look at the generated errors in syntastic wrong (which it may very well be)?
As a side note for the question here, I've also got this question in on the Syntastic github page here.
It turns out that the errorformat was wrong for handling icc. This, of course, makes total sense.
The errorformat for icc that I've got so far is:
let errorformat = '%W%f(%l): %tarning #%n: %m,%E%f(%l): %trror: %m'
I will add more to this as I find errors that aren't covered by this format or find that I need different formatting.

Resources