New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #10: Added magics to provide LDFLAGS and CFLAGS to gcc #26

Merged
merged 1 commit into from Apr 12, 2017

Conversation

Projects
None yet
3 participants
@spoorcc

spoorcc commented Apr 12, 2017

This PR implements fix for #10. Adds support for passing linker flags and cflags to gcc.
Ipython notebooks use magics for passing flags. This PR makes CKernel filter out lines starting with //% after which key value pair can be added e.g.:

  • //% LDFLAGS: -lm
  • //% CFLAGS: -Werror

Currently only LDFLAGS and CFLAGS are accepted (case-insensitive), but this can be extended later on for more.

Passing cflags example

//% cflags: -Werror
int main() {
    printf("Hello world\n");
}

This will now result in failed run since -Werror makes the warning an error:

error: incompatible implicit declaration of built-in function ‘printf’ [-Werror]

Passing ldflags example:

When you for instance need stdmath for showing the sin or cos functions, LDFLAG -lm needs to be provide to gcc. Following code will now be compiled, linked and run succesfully.

//% ldflags: -lm
/* cos example */
#include <stdio.h>      /* printf */
#include <math.h>       /* cos */

#define PI 3.14159265

int main ()
{
  double param, result;
  param = 60.0;
  result = cos ( param * PI / 180.0 );
  printf ("The cosine of %f degrees is %f.\n", param, result );
  return 0;
}

@brendan-rius brendan-rius merged commit 17316fb into brendan-rius:master Apr 12, 2017

@brendan-rius

This comment has been minimized.

Owner

brendan-rius commented Apr 12, 2017

Thank you!

@spoorcc

This comment has been minimized.

spoorcc commented Apr 12, 2017

No problem!

@spoorcc spoorcc deleted the spoorcc:issue-10 branch Apr 13, 2017

@spoorcc spoorcc referenced this pull request Apr 13, 2017

Closed

math functions? #15

@fedele

This comment has been minimized.

fedele commented Jun 28, 2017

For me it is not working.
Can you help?

@spoorcc

This comment has been minimized.

spoorcc commented Jun 28, 2017

@fedele

This comment has been minimized.

fedele commented Jun 28, 2017

@spoorcc

This comment has been minimized.

spoorcc commented Jun 28, 2017

  • What was the contents of your cell?
  • What was the output of your notebook?

Sent from my OnePlus ONEPLUS A5000 using FastHub

@fedele

This comment has been minimized.

fedele commented Jun 28, 2017

@spoorcc

This comment has been minimized.

spoorcc commented Jun 28, 2017

All I can think of now is that you might be missing a space after the //%

Sent from my OnePlus ONEPLUS A5000 using FastHub

@fedele

This comment has been minimized.

fedele commented Jun 28, 2017

@fedele

This comment has been minimized.

fedele commented Jun 29, 2017

@spoorcc

This comment has been minimized.

spoorcc commented Jun 29, 2017

I think you are missing the colon :

//% ldflags: -lm

@fedele

This comment has been minimized.

fedele commented Jun 29, 2017

@fedele

This comment has been minimized.

fedele commented Jun 29, 2017

@fedele

This comment has been minimized.

fedele commented Jun 29, 2017

@spoorcc

This comment has been minimized.

spoorcc commented Jun 29, 2017

Snap, I was hoping it was that easy, just missing a colon 😄

  • Did you check the magics parsing (this PR) is in the Jupyter-c-kernel code you are running?
  • Does the //% cflags: -Werror example from above work?
@fedele

This comment has been minimized.

fedele commented Jun 29, 2017

@fedele

This comment has been minimized.

fedele commented Jun 29, 2017

@spoorcc

This comment has been minimized.

spoorcc commented Jun 29, 2017

Great! Then it is probably not my fault 😀

How did you install?

Using the install script:
wget -O - https://raw.githubusercontent.com/brendan-rius/jupyter-c-kernel/master/install.sh | sh should give you the latest version from master.

@fedele

This comment has been minimized.

fedele commented Jun 29, 2017

@spoorcc

This comment has been minimized.

spoorcc commented Jun 29, 2017

I created a new issue #29 to update it, to solve it for other people as well

@fedele

This comment has been minimized.

fedele commented Jun 29, 2017

@fedele

This comment has been minimized.

fedele commented Jun 29, 2017

@fedele

This comment has been minimized.

fedele commented Jun 30, 2017

@spoorcc

This comment has been minimized.

spoorcc commented Jun 30, 2017

Github has some nice guides for instance:

But I would recommend to create an issue, and propose your solution to the maintainer of the project if you're not completely sure.

Sent from my OnePlus ONEPLUS A5000 using FastHub

@fedele

This comment has been minimized.

fedele commented Jun 30, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment