问:
create Dynamic table in PHP While loop
I have data from my query result like this :

```<code>DATE           DEPTH    LOCATION    idx
2010-08-13      0.34    SAKE RIVER  1
2010-08-13      0.35    SAKE RIVER  2
2010-08-13      0.35    SAKE RIVER  3
2016-01-30     1.463    AKE KOBE    4
2016-04-12     1.524    AKE KOBE    5
2014-05-13      1.03    AKE KOBE    6
2008-12-16     0.617    SAGEA           7
2008-08-11     1.503    SAGEA           8
2008-07-03     1.369    SAGEA           9
</code>```

how to loop this query result to create dynamic table in one index page
like this:

```<code><span>SAKE RIVER<span>
<Table>
 <tr>
<th>IDX</th>
<th>DATETIME</th>
<th>DEPTH</th>
</tr>
 <tr>
  <td>VAL</td>
  <td>VAL</td>
  <td>VAL</td>
  </tr>
</Table>

<span>AKE KOBE<span>
<Table>
 <tr>
<th>IDX</th>
<th>DATETIME</th>
<th>DEPTH</th>
</tr>
 <tr>
  <td>VAL</td>
  <td>VAL</td>
  <td>VAL</td>
  </tr>
</Table>

<span>SAGEA<span>
<Table>
 <tr>
<th>IDX</th>
<th>DATETIME</th>
<th>DEPTH</th>
</tr>
 <tr>
  <td>VAL</td>
  <td>VAL</td>
  <td>VAL</td>
  </tr>
</Table>
</code>```

If add more location than it will create more table

Thankyou

sorry for my english

答:
```<code><?php
 $sql = "SELECT * FROM table_name";
 $query = mysqli_query($connection, $sql);
 while($row = mysqli_fetch_assoc()){
 echo $row['location']; ?>

<table>
<thead>
 <tr>
 <td>DATE</td>
 <td>DEPTH</td>
 <td>LOCATION</td>
 <td>idx</td>
 </tr>
 </thead>
 <tdbody>
 <tr>
 <?php
 echo "<td>".$row['date']."</td>";
 echo "<td>".$row['depth']."</td>";
 echo "<td>".$row['location']."</td>";
 echo "<td>".$row['idx']."</td>";
 ?>
 </tr>
 </tdbody>
 </table>
<?php } ?>
</code>```

Hope it helps.

Title: create Dynamic table in PHP While loop

Body:
I have data from my query result like this :

DATE           DEPTH    LOCATION    idx
2010-08-13      0.34    SAKE RIVER  1
2010-08-13      0.35    SAKE RIVER  2
2010-08-13      0.35    SAKE RIVER  3
2016-01-30     1.463    AKE KOBE    4
2016-04-12     1.524    AKE KOBE    5
2014-05-13      1.03    AKE KOBE    6
2008-12-16     0.617    SAGEA           7
2008-08-11     1.503    SAGEA           8
2008-07-03     1.369    SAGEA           9

how to loop this query result to create dynamic table in one index page
like this:

SAKE RIVER

IDX
DATETIME
DEPTH

  VAL
  VAL
  VAL

AKE KOBE

IDX
DATETIME
DEPTH

  VAL
  VAL
  VAL

SAGEA

IDX
DATETIME
DEPTH

  VAL
  VAL
  VAL

If add more location than it will create more table

Thankyou

sorry for my english

Body:
<?php
 $sql = "SELECT * FROM table_name";
 $query = mysqli_query($connection, $sql);
 while($row = mysqli_fetch_assoc()){
 echo $row['location']; ?>

<table>
<thead>
 <tr>
 <td>DATE</td>
 <td>DEPTH</td>
 <td>LOCATION</td>
 <td>idx</td>
 </tr>
 </thead>
 <tdbody>
 <tr>
 <?php
 echo "<td>".$row['date']."</td>";
 echo "<td>".$row['depth']."</td>";
 echo "<td>".$row['location']."</td>";
 echo "<td>".$row['idx']."</td>";
 ?>
 </tr>
 </tdbody>
 </table>
<?php } ?>

Hope it helps.


来源: stackexchange

问:
OpenCart 3.0 (3.x) + Authorize.net - how to disable ONLY the Authorize.net E-mail?
We currently accept credit cards by phone (entering the order info into the Virtual Terminal) as well as on the website (OpenCart, using the built-in Authorize.net AIM module).

Problem: when order is placed on website, the customer receives 2 E-mails - 1 from our site, 1 from Authorize. The Authorize E-mail, being plaintext, looks ugly AF, and my boss wants to have it disabled.

Attempt # 1: looked in the Authorize.net AIM plugin/module settings. No such option.

Attempt # 2: in the Authorize.net account, under "Settings -> E-mail Receipt", there is a checkbox "Email transaction receipt to customer (if email address is provided)".

Result #2:  unfortunately, this disables ALL transaction E-mails - from website transactions (OK) and from Virtual Terminal phone-order transactions (NOT cool). We have to provide an E-mail receipt to phone customers.

Attempt #3: in the OpenCart system, editing file:

```<code>catalog/controller/extension/payment/authorizenet_aim.php
</code>```

to comment out the line

```<code>$data['x_email'] = $order_info['email'];
</code>```

Result #3: during checkout, even if a valid E-mail is entered, upon trying to submit the order, the "Email address is required" error message appears.

So...
Can't disable it in Authorize plugin/module in OpenCart.
Can't disable it in Authorize Account Settings.
Can't just delete the E-mail from the array of data that OpenCart collects during checkout.

How can I disable the Authorize.net E-mail (and ONLY the Authorize.net E-mail, I still want the website receipt to go out) on a site built on OpenCart 3.0?

答: This isn't a great solution but could you change the email address that gets sent to Authorize.net to be the store admin email, in that case it won't give you the "Email address is required" error message and you'll get that email instead of the customer.</p>

ContentLicense: CC BY-SA 3.0

Body:
We currently accept credit cards by phone (entering the order info into the Virtual Terminal) as well as on the website (OpenCart, using the built-in Authorize.net AIM module).

Problem: when order is placed on website, the customer receives 2 E-mails - 1 from our site, 1 from Authorize. The Authorize E-mail, being plaintext, looks ugly AF, and my boss wants to have it disabled.

Attempt # 1: looked in the Authorize.net AIM plugin/module settings. No such option.

Attempt # 2: in the Authorize.net account, under "Settings -> E-mail Receipt", there is a checkbox "Email transaction receipt to customer (if email address is provided)".

Result #2:  unfortunately, this disables ALL transaction E-mails - from website transactions (OK) and from Virtual Terminal phone-order transactions (NOT cool). We have to provide an E-mail receipt to phone customers.

Attempt #3: in the OpenCart system, editing file:

catalog/controller/extension/payment/authorizenet_aim.php

to comment out the line

$data['x_email'] = $order_info['email'];

Result #3: during checkout, even if a valid E-mail is entered, upon trying to submit the order, the "Email address is required" error message appears.

So...
Can't disable it in Authorize plugin/module in OpenCart.
Can't disable it in Authorize Account Settings.
Can't just delete the E-mail from the array of data that OpenCart collects during checkout.

How can I disable the Authorize.net E-mail (and ONLY the Authorize.net E-mail, I still want the website receipt to go out) on a site built on OpenCart 3.0?


问:
mysql querys show row type once
Say I have 3 columns named 'page', 'book info' with various values one being 'author', the and 'book data' where I would have values such as 'dan brown', 'moliere'... I could have many pages with moliere being the author. My query is currently:

$data = mysql_query("SELECT * FROM table WHERE 'book info' = 'author'")
while($info = mysql_fetch_array( $data )) { echo $info['book data']; }

This lists all of the authors, as said earlier 'moliere' appears many times, how would I only list an author once?

答:
You can say to the RDBMS to return only distinct rows either with the DISTINCT keyword:

```<code>SELECT DISTINCT `book data` FROM table WHERE `book info` = 'author'
</code>```

So MySQL will return only one row for each different book data value.

Or with a GROUP:

```<code>SELECT `book data`, other_column FROM table WHERE `book info` = 'author' GROUP BY `book data`, other_column
</code>```

ContentLicense: CC BY-SA 2.5

Title: mysql querys show row type once

Body:
You can say to the RDBMS to return only distinct rows either with the DISTINCT keyword:

SELECT DISTINCT `book data` FROM table WHERE `book info` = 'author'

So MySQL will return only one row for each different book data value.

Or with a GROUP:

SELECT `book data`, other_column FROM table WHERE `book info` = 'author' GROUP BY `book data`, other_column


问:
Failed to convert parameter value from a String to a Byte[]
net code and I am facing this issue when I am trying to insert string in Binary format.

I Have binary format of image in decal.DecalLogoFileName and decal.DecalLogoFileName is define a string so when I am trying as

```<code>cmd.Parameters.Add(new SqlParameter("@DecalLogoFileName", SqlDbType.Binary)).Value=decal.DecalLogoFileName;

decal.DecalLogoFileName="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxITEhUTExIWFhUXGB8aGBcYGR0ZHxobGhoXHRcYGBkaHyghHRolHRcXIjEhJSkrLi4uGB8zODMtNygtLisBCgoKDg0OGhAQGy0lHyUtLS0tLS0tLS0tLS0tLy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tLf/AABEIALcBEwMBIgACEQEDEQH/xAAbAAACAwEBAQAAAAAAAAAAAAAEBQIDBgABB//EAEgQAAIBAgQDBQQHBQYDCAMAAAECEQADBBIhMQVBUQYTImFxMoGRoSNCUrHB0fAUcpLS4QczU2KCshVUc0Njg5OiwuLxFiRk/8QAGQEAAwEBAQAAAAAAAAAAAAAAAQIDAAQF/8QALBEAAgICAgECBQQCAwAAAAAAAAECERIhAzFBE2EiMlFxgUKhsdEEkSMzUv/aAAwDAQACEQMRAD8A"
</code>```

I am string value in decal as

```<code>function readURL(input) {
if (input.files && input.files[0]) {
        var reader = new FileReader();
        reader.onload = function (e) {
            $('#DecalLogo').attr('src', e.target.result);
            $('#hdImageName').val(e.target.result);
        }
        reader.readAsDataURL(input.files[0]);
    }
}
</code>```

here hdImageName value is store in decal.DecalLogoFileName

I had also tried

```<code>cmd.Parameters.Add(new SqlParameter("@DecalLogoFileName", SqlDbType.Binary)).Value=Convert.toByte(decal.DecalLogoFileName);
</code>```

But Conversion issue is coming.

The column datatype of DecalLogoFileName is set as varbinary(MAX)

答:
Try like this;

```<code>var byteArray = Encoding.ASCII.GetBytes(decal.DecalLogoFileName);
cmd.Parameters.Add(new SqlParameter("@DecalLogoFileName", SqlDbType.VarBinary, byteArray.Length)).Value=byteArray;
</code>```

To retrieve the image from database, you can convert it base64 string by using Encoding.ASCII.GetString(byteArray). Then you can put the image in img src like this;

```<code>        <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxITEhUTExIWFhUXGB8aGBcYGR0ZHxobGhoXHRcYGBkaHyghHRolHRcXIjEhJSkrLi4uGB8zODMtNygtLisBCgoKDg0OGhAQGy0lHyUtLS0tLS0tLS0tLS0tLy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tLf/AABEIALcBEwMBIgACEQEDEQH/xAAbAAACAwEBAQAAAAAAAAAAAAAEBQIDBgABB//EAEgQAAIBAgQDBQQHBQYDCAMAAAECEQADBBIhMQVBUQYTImFxMoGRoSNCUrHB0fAUcpLS4QczU2KCshVUc0Njg5OiwuLxFiRk/8QAGQEAAwEBAQAAAAAAAAAAAAAAAQIDAAQF/8QALBEAAgICAgECBQQCAwAAAAAAAAECERIhAzFBE2EiMlFxgUKhsdEEkSMzUv/aAAwDAQACEQMRAD8A"
        alt="SampleImage" />
</code>```

Body:
net code and I am facing this issue when I am trying to insert string in Binary format.

I Have binary format of image in decal.DecalLogoFileName and decal.DecalLogoFileName is define a string so when I am trying as

cmd.Parameters.Add(new SqlParameter("@DecalLogoFileName", SqlDbType.Binary)).Value=decal.DecalLogoFileName;

decal.DecalLogoFileName="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxITEhUTExIWFhUXGB8aGBcYGR0ZHxobGhoXHRcYGBkaHyghHRolHRcXIjEhJSkrLi4uGB8zODMtNygtLisBCgoKDg0OGhAQGy0lHyUtLS0tLS0tLS0tLS0tLy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tLf/AABEIALcBEwMBIgACEQEDEQH/xAAbAAACAwEBAQAAAAAAAAAAAAAEBQIDBgABB//EAEgQAAIBAgQDBQQHBQYDCAMAAAECEQADBBIhMQVBUQYTImFxMoGRoSNCUrHB0fAUcpLS4QczU2KCshVUc0Njg5OiwuLxFiRk/8QAGQEAAwEBAQAAAAAAAAAAAAAAAQIDAAQF/8QALBEAAgICAgECBQQCAwAAAAAAAAECERIhAzFBE2EiMlFxgUKhsdEEkSMzUv/aAAwDAQACEQMRAD8A"

I am string value in decal as

function readURL(input) {
if (input.files && input.files[0]) {
        var reader = new FileReader();
        reader.onload = function (e) {
            $('#DecalLogo').attr('src', e.target.result);
            $('#hdImageName').val(e.target.result);
        }
        reader.readAsDataURL(input.files[0]);
    }
}

here hdImageName value is store in decal.DecalLogoFileName

I had also tried

cmd.Parameters.Add(new SqlParameter("@DecalLogoFileName", SqlDbType.Binary)).Value=Convert.toByte(decal.DecalLogoFileName);

But Conversion issue is coming.

The column datatype of DecalLogoFileName is set as varbinary(MAX)

Body:
Try like this;

var byteArray = Encoding.ASCII.GetBytes(decal.DecalLogoFileName);
cmd.Parameters.Add(new SqlParameter("@DecalLogoFileName", SqlDbType.VarBinary, byteArray.Length)).Value=byteArray;

To retrieve the image from database, you can convert it base64 string by using Encoding.ASCII.GetString(byteArray). Then you can put the image in img src like this;

        <img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBxITEhUTExIWFhUXGB8aGBcYGR0ZHxobGhoXHRcYGBkaHyghHRolHRcXIjEhJSkrLi4uGB8zODMtNygtLisBCgoKDg0OGhAQGy0lHyUtLS0tLS0tLS0tLS0tLy0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLSstLS0tLS0tLS0tLf/AABEIALcBEwMBIgACEQEDEQH/xAAbAAACAwEBAQAAAAAAAAAAAAAEBQIDBgABB//EAEgQAAIBAgQDBQQHBQYDCAMAAAECEQADBBIhMQVBUQYTImFxMoGRoSNCUrHB0fAUcpLS4QczU2KCshVUc0Njg5OiwuLxFiRk/8QAGQEAAwEBAQAAAAAAAAAAAAAAAQIDAAQF/8QALBEAAgICAgECBQQCAwAAAAAAAAECERIhAzFBE2EiMlFxgUKhsdEEkSMzUv/aAAwDAQACEQMRAD8A"
        alt="SampleImage" />


问:
AttributeError: StringIO instance has no attribute 'encoding'
While using PyCharm's interactive console when debugging nosetests, I get the following error:

```<code>AttributeError: StringIO instance has no attribute 'encoding'
</code>```

I found some guidance here, but I don't know how to apply it to my situation.

How can I resolve this issue?

Full Stack Trace:

```<code>Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 1409, in do_it
    result = pydevconsole.console_exec(self.thread_id, self.frame_id, self.expression, dbg)
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\helpers\pydev\pydevconsole.py", line 475, in console_exec
    need_more =  exec_code(CodeFragment(expression), updated_globals, frame.f_locals, dbg)
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\helpers\pydev\pydevconsole.py", line 392, in exec_code
    interpreterInterface = get_interpreter()
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\helpers\pydev\pydevconsole.py", line 372, in get_interpreter
    interpreterInterface = InterpreterInterface(None, None, threading.currentThread())
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\helpers\pydev\_pydev_bundle\pydev_ipython_console.py", line 25, in __init__
    self.interpreter = get_pydev_frontend(host, client_port, show_banner=show_banner)
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\helpers\pydev\_pydev_bundle\pydev_ipython_console_011.py", line 488, in get_pydev_frontend
    _PyDevFrontEndContainer._instance = _PyDevFrontEnd(show_banner=show_banner)
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\helpers\pydev\_pydev_bundle\pydev_ipython_console_011.py", line 318, in __init__
    self.ipython = PyDevTerminalInteractiveShell.instance()
  File "C:\Users\jimgo\Anaconda2\lib\site-packages\traitlets\config\configurable.py", line 412, in instance
    inst = cls(*args, **kwargs)
  File "C:\Users\jimgo\Anaconda2\lib\site-packages\IPython\terminal\interactiveshell.py", line 396, in __init__
    super(TerminalInteractiveShell, self).__init__(*args, **kwargs)
  File "C:\Users\jimgo\Anaconda2\lib\site-packages\IPython\core\interactiveshell.py", line 499, in __init__
    self.init_io()
  File "C:\Users\jimgo\Anaconda2\lib\site-packages\IPython\terminal\interactiveshell.py", line 363, in init_io
    self.enable_win_unicode_console()
  File "C:\Users\jimgo\Anaconda2\lib\site-packages\IPython\terminal\interactiveshell.py", line 357, in enable_win_unicode_console
    stderr=stderr_text_str)
  File "C:\Users\jimgo\Anaconda2\lib\site-packages\win_unicode_console\__init__.py", line 31, in enable
    readline_hook.enable(use_pyreadline=use_pyreadline)
  File "C:\Users\jimgo\Anaconda2\lib\site-packages\win_unicode_console\readline_hook.py", line 134, in enable
    check_encodings()
  File "C:\Users\jimgo\Anaconda2\lib\site-packages\win_unicode_console\readline_hook.py", line 50, in check_encodings
    if sys.stdin.encoding != sys.stdout.encoding:
AttributeError: StringIO instance has no attribute 'encoding'
</code>```

答:
There's an issue on the JetBrains bug tracker with a solution.

In PyCharm, go to Run > Edit Configurations > Defaults > Python tests > Nosetests. Under Additional arguments put --nocapture. Then delete all the existing test configurations from the top of the left-hand pane.

Try to debug your test again. Don't click the re-test button from the debug panel because this seems to reuse the previous configuration. Instead run the test again by right clicking on the test file for instance.

Body:
While using PyCharm's interactive console when debugging nosetests, I get the following error:

AttributeError: StringIO instance has no attribute 'encoding'

I found some guidance here, but I don't know how to apply it to my situation.

How can I resolve this issue?

Full Stack Trace:

Traceback (most recent call last):
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 1409, in do_it
    result = pydevconsole.console_exec(self.thread_id, self.frame_id, self.expression, dbg)
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\helpers\pydev\pydevconsole.py", line 475, in console_exec
    need_more =  exec_code(CodeFragment(expression), updated_globals, frame.f_locals, dbg)
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\helpers\pydev\pydevconsole.py", line 392, in exec_code
    interpreterInterface = get_interpreter()
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\helpers\pydev\pydevconsole.py", line 372, in get_interpreter
    interpreterInterface = InterpreterInterface(None, None, threading.currentThread())
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\helpers\pydev\_pydev_bundle\pydev_ipython_console.py", line 25, in __init__
    self.interpreter = get_pydev_frontend(host, client_port, show_banner=show_banner)
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\helpers\pydev\_pydev_bundle\pydev_ipython_console_011.py", line 488, in get_pydev_frontend
    _PyDevFrontEndContainer._instance = _PyDevFrontEnd(show_banner=show_banner)
  File "C:\Program Files (x86)\JetBrains\PyCharm 2016.3.2\helpers\pydev\_pydev_bundle\pydev_ipython_console_011.py", line 318, in __init__
    self.ipython = PyDevTerminalInteractiveShell.instance()
  File "C:\Users\jimgo\Anaconda2\lib\site-packages\traitlets\config\configurable.py", line 412, in instance
    inst = cls(*args, **kwargs)
  File "C:\Users\jimgo\Anaconda2\lib\site-packages\IPython\terminal\interactiveshell.py", line 396, in __init__
    super(TerminalInteractiveShell, self).__init__(*args, **kwargs)
  File "C:\Users\jimgo\Anaconda2\lib\site-packages\IPython\core\interactiveshell.py", line 499, in __init__
    self.init_io()
  File "C:\Users\jimgo\Anaconda2\lib\site-packages\IPython\terminal\interactiveshell.py", line 363, in init_io
    self.enable_win_unicode_console()
  File "C:\Users\jimgo\Anaconda2\lib\site-packages\IPython\terminal\interactiveshell.py", line 357, in enable_win_unicode_console
    stderr=stderr_text_str)
  File "C:\Users\jimgo\Anaconda2\lib\site-packages\win_unicode_console\__init__.py", line 31, in enable
    readline_hook.enable(use_pyreadline=use_pyreadline)
  File "C:\Users\jimgo\Anaconda2\lib\site-packages\win_unicode_console\readline_hook.py", line 134, in enable
    check_encodings()
  File "C:\Users\jimgo\Anaconda2\lib\site-packages\win_unicode_console\readline_hook.py", line 50, in check_encodings
    if sys.stdin.encoding != sys.stdout.encoding:
AttributeError: StringIO instance has no attribute 'encoding'


问:
React JS: How can I set state of an array nested in an object nested in an array
I want to set the state of my component after a certain amount time but the problem is that the state is an array nested in an object nested in an array.
Here is my code:

```<code>this.state = {
items: {
    label: ['A', 'B', 'C', 'D'],
    data: [
        {
            label: 'A',
            value: [1, 2, 3, 4, 5]
        }
      ]
    }
  }
</code>```

I want to change the state of value to the following:

```<code>value: ["a", "b", "c", "d"]
</code>```

How can I achieve this?

答:
You can achieve this like this:

```<code>this.state.items.data[0].value = ["a", "b", "c", "d"];
this.setState({items: this.state.items });
</code>```

If you want something to update which is nested. First update the value directly in the state obj (line 1) and then do setState for the state variable(line2)

ContentLicense: CC BY-SA 4.0

Body:
I want to set the state of my component after a certain amount time but the problem is that the state is an array nested in an object nested in an array.
Here is my code:

this.state = {
items: {
    label: ['A', 'B', 'C', 'D'],
    data: [
        {
            label: 'A',
            value: [1, 2, 3, 4, 5]
        }
      ]
    }
  }

I want to change the state of value to the following:

value: ["a", "b", "c", "d"]

How can I achieve this?

Body:
You can achieve this like this:

this.state.items.data[0].value = ["a", "b", "c", "d"];
this.setState({items: this.state.items });

If you want something to update which is nested. First update the value directly in the state obj (line 1) and then do setState for the state variable(line2)


问:
How to make pane and elements in it resizable when stage size is changing
Can you please tell me how can I realize that the whole content of a pane will be resized while the stage is resized with mousedragg. Here is my code:

```<code>public class fab extends Application {
private Stage stage;
private Pane pane;
private Scene scene;

@Override
public void start(Stage stage) throws Exception {

this.stage = stage;

Button button = new Button("Button");

pane = new Pane();
pane.getChildren().add(button);

stage.setTitle("Test");
scene = new Scene(pane, 640, 640);
stage.setScene(scene);
stage.show();

}

public static void main(String[] args) {
    launch(args);
}
</code>```

I think there is the idea of binding. But I don't know how to use that, in order  to make all nodes of a pane resizable, when the stage size is changing.

I'm searching a solution without Fxml or sceneBuilder.

Thank you in advance.

答:
If you insists to use the Pane container then  after the line scene = new Scene(pane, 640, 640);  add this:

```<code>scene.widthProperty().addListener((c,o,n)->button.setPrefWidth((Double)n));
scene.heightProperty().addListener((c,o,n)->button.setPrefHeight((Double)n));
</code>```

and after the line stage.setScene(scene);  add this:

```<code>button.setPrefSize(scene.getWidth(), scene.getHeight());
</code>```

This works fine with Pane and do your required thing.

But I prefer using an AnchorPane container and set the Top, Right,Bottom and Left anchors to 0 .

Body:
Can you please tell me how can I realize that the whole content of a pane will be resized while the stage is resized with mousedragg. Here is my code:

public class fab extends Application {
private Stage stage;
private Pane pane;
private Scene scene;

@Override
public void start(Stage stage) throws Exception {

this.stage = stage;

Button button = new Button("Button");

pane = new Pane();
pane.getChildren().add(button);

stage.setTitle("Test");
scene = new Scene(pane, 640, 640);
stage.setScene(scene);
stage.show();

}

public static void main(String[] args) {
    launch(args);
}

I think there is the idea of binding. But I don't know how to use that, in order  to make all nodes of a pane resizable, when the stage size is changing.

I'm searching a solution without Fxml or sceneBuilder.

Thank you in advance.

Body:
If you insists to use the Pane container then  after the line scene = new Scene(pane, 640, 640);  add this:

scene.widthProperty().addListener((c,o,n)->button.setPrefWidth((Double)n));
scene.heightProperty().addListener((c,o,n)->button.setPrefHeight((Double)n));

and after the line stage.setScene(scene);  add this:

button.setPrefSize(scene.getWidth(), scene.getHeight());

This works fine with Pane and do your required thing.

But I prefer using an AnchorPane container and set the Top, Right,Bottom and Left anchors to 0 .


问:
Selenium Webdriver Java: How to click on a particular cell in table using row and column numbers
I have written a code to verify if a given text is present in that row or not but how do i click in a  particular cell? Please help me.

Below is the code i have written for verifying the text.

```<code>package com.Tables;

import java.util.List;

public class HandlingTables {

public static void main(String[] args) throws InterruptedException {
    String s="";
    System.setProperty("webdriver.chrome.driver", "D:/chromedriver.exe");
    WebDriver driver = new ChromeDriver();
    driver.get("http://www.w3schools.com/html/html_tables.asp");
    WebElement table = driver.findElement(By.className("w3-table-all"));
    List<WebElement> allrows = table.findElements(By.tagName("tr"));
    List<WebElement> allcols = table.findElements(By.tagName("td"));
    System.out.println("Number of rows in the table "+allrows.size());
    System.out.println("Number of columns in the table "+allcols.size());

    for(WebElement row: allrows){
        List<WebElement> Cells = row.findElements(By.tagName("td"));
        for(WebElement Cell:Cells){
            s = s.concat(Cell.getText());
        }
    }
    System.out.println(s);
    if(s.contains("Jackson")){
        System.out.println("Jackson is present in the table");
    }else{
        System.out.println("Jackson is not available in the table");
    }
    Thread.sleep(10000);
    driver.quit();
  }
}
</code>```

答:
You will have to build a dynamic selector to achieve this.

For example:

```<code>private String rowRootSelector = "tr";
private String specificCellRoot = rowRootSelector + ":nth-of-type(%d) > td:nth-of-type(%d)";
</code>```

And in the method where you take Row and Column as input parameter, the selector has to be built.

```<code>String selector = String.format(specificCellRoot, rowIndex, columnIndex);
</code>```

And, now you can click or do any other operation on that web element.

```<code>driver.findElement(By.cssSelector(selector));
</code>```

Body:
I have written a code to verify if a given text is present in that row or not but how do i click in a  particular cell? Please help me.

Below is the code i have written for verifying the text.

package com.Tables;

import java.util.List;

public class HandlingTables {

public static void main(String[] args) throws InterruptedException {
    String s="";
    System.setProperty("webdriver.chrome.driver", "D:/chromedriver.exe");
    WebDriver driver = new ChromeDriver();
    driver.get("http://www.w3schools.com/html/html_tables.asp");
    WebElement table = driver.findElement(By.className("w3-table-all"));
    List<WebElement> allrows = table.findElements(By.tagName("tr"));
    List<WebElement> allcols = table.findElements(By.tagName("td"));
    System.out.println("Number of rows in the table "+allrows.size());
    System.out.println("Number of columns in the table "+allcols.size());

    for(WebElement row: allrows){
        List<WebElement> Cells = row.findElements(By.tagName("td"));
        for(WebElement Cell:Cells){
            s = s.concat(Cell.getText());
        }
    }
    System.out.println(s);
    if(s.contains("Jackson")){
        System.out.println("Jackson is present in the table");
    }else{
        System.out.println("Jackson is not available in the table");
    }
    Thread.sleep(10000);
    driver.quit();
  }
}

Body:
You will have to build a dynamic selector to achieve this.

For example:

private String rowRootSelector = "tr";
private String specificCellRoot = rowRootSelector + ":nth-of-type(%d) > td:nth-of-type(%d)";

And in the method where you take Row and Column as input parameter, the selector has to be built.

String selector = String.format(specificCellRoot, rowIndex, columnIndex);

And, now you can click or do any other operation on that web element.

driver.findElement(By.cssSelector(selector));


问:
PHP rename variable to unique value returns 1
I have a file name which I need to give a unique name to in PHP. The file looks like this:

orders_dd-mm-yy#hh:mm:ss.csv

I want to change it to:

orders_dd-mm-yy_uniquevalue.csv

As I believe the hash and colons are causing issues when I try to import the CSV file into an SQL database.

However when I use this code to change the variable, it becomes a '1':

```<code>$file = rename('/var/www/html/' . $file, '/var/www/html/' . explode('#', $file))[0] . '_' . uniqid() . '.csv';
</code>```

What am I doing wrong?

答:
Thanks to Yoshi's comment, I have been able to figure out where I was going wrong.

This has worked for me:

```<code>$fileNew = explode('/var/www/html/' . $file)[0] . '.csv';
rename('/var/www/html/' . $file, '/var/www/html/' . $fileNew);
$file = $fileNew;
</code>```

Body:
I have a file name which I need to give a unique name to in PHP. The file looks like this:

orders_dd-mm-yy#hh:mm:ss.csv

I want to change it to:

orders_dd-mm-yy_uniquevalue.csv

As I believe the hash and colons are causing issues when I try to import the CSV file into an SQL database.

However when I use this code to change the variable, it becomes a '1':

$file = rename('/var/www/html/' . $file, '/var/www/html/' . explode('#', $file))[0] . '_' . uniqid() . '.csv';

What am I doing wrong?

Body:
Thanks to Yoshi's comment, I have been able to figure out where I was going wrong.

This has worked for me:

$fileNew = explode('/var/www/html/' . $file)[0] . '.csv';
rename('/var/www/html/' . $file, '/var/www/html/' . $fileNew);
$file = $fileNew;


答:
You can use grouping:

```<code>SELECT * FROM table GROUP BY `book info`
</code>```

which allows you for example to track the number of books written by each author:

```<code>SELECT count(`page`) FROM table GROUP BY `book info`
</code>```

Title: mysql querys show row type once

Body:
Say I have 3 columns named 'page', 'book info' with various values one being 'author', the and 'book data' where I would have values such as 'dan brown', 'moliere'... I could have many pages with moliere being the author. My query is currently:

$data = mysql_query("SELECT * FROM table WHERE 'book info' = 'author'")
while($info = mysql_fetch_array( $data )) { echo $info['book data']; }

This lists all of the authors, as said earlier 'moliere' appears many times, how would I only list an author once?

Body:
You can use grouping:

SELECT * FROM table GROUP BY `book info`

which allows you for example to track the number of books written by each author:

SELECT count(`page`) FROM table GROUP BY `book info`


问:
Symfony 4 deployment not working
I'm trying to deploy a symfony 4 project in my server, but I'm having problems to acomplish it production (in local it works perfect).

Previously I have deployed a lot of symfony 3 projects in my server, so I decided to test a Symfony 4.

This is the error that I'm getting in my log:

[Wed Dec 06 10:26:33.141952 2017] [:error] [pid 13485] [client 84.120.210.249:50394] PHP Fatal error:  Uncaught TypeError: Return value of Symfony\Component\Dotenv\Dotenv::populate() must be an instance of Symfony\Component\Dotenv\void, none returned in /var/www/my_project/vendor/symfony/dotenv/Dotenv.php:95\nStack trace:\n#0 /var/www/my_project/vendor/symfony/dotenv/Dotenv.php(57): Symfony\Component\Dotenv\Dotenv->populate(Array)\n#1 /var/www/my_project/public/index.php(15): Symfony\Component\Dotenv\Dotenv->load('/var/www/rodage...')\n#2 {main}\n  thrown in /var/www/my_project/vendor/symfony/dotenv/Dotenv.php on line 95

This is my index.php (default index.php that you get when you create a project):

```<code><?php

use App\Kernel;
use Symfony\Component\Debug\Debug;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\HttpFoundation\Request;

require __DIR__.'/../vendor/autoload.php';

// The check is to ensure we don't use .env in production
if (!isset($_SERVER['APP_ENV'])) {
    if (!class_exists(Dotenv::class)) {
        throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
    }
    (new Dotenv())->load(__DIR__.'/../.env');
}

if ($_SERVER['APP_DEBUG'] ?? ('prod' !== ($_SERVER['APP_ENV'] ?? 'dev'))) {
    umask(0000);

    Debug::enable();
}

if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? false) {
    Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}

if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? false) {
    Request::setTrustedHosts(explode(',', $trustedHosts));
}

$kernel = new Kernel($_SERVER['APP_ENV'] ?? 'dev', $_SERVER['APP_DEBUG'] ?? ('prod' !== ($_SERVER['APP_ENV'] ?? 'dev')));
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
</code>```

This is what I have in my composer.json:

```<code>"require": {
    "php": "^7.1.3",
    "symfony/asset": "^4.0",
    "symfony/console": "^4.0",
    "symfony/dotenv": "^4.0",
    "symfony/flex": "^1.0",
    "symfony/framework-bundle": "^4.0",
    "symfony/lts": "^4@dev",
    "symfony/twig-bundle": "^4.0",
    "symfony/web-server-bundle": "^4.0",
    "symfony/yaml": "^4.0"
},
</code>```

These are the things that I tried:

-cache:clear

-composer update

-apache restart

I think that it something about environment variables, but not really sure...

Any suggestions?

Thank you all for your time!

答:
Void returns are only available from PHP 7.1. My guess is that you are using an earlier version of PHP.

Look at this answer

Title: Symfony 4 deployment not working

Body:
I'm trying to deploy a symfony 4 project in my server, but I'm having problems to acomplish it production (in local it works perfect).

Previously I have deployed a lot of symfony 3 projects in my server, so I decided to test a Symfony 4.

This is the error that I'm getting in my log:

[Wed Dec 06 10:26:33.141952 2017] [:error] [pid 13485] [client 84.120.210.249:50394] PHP Fatal error:  Uncaught TypeError: Return value of Symfony\Component\Dotenv\Dotenv::populate() must be an instance of Symfony\Component\Dotenv\void, none returned in /var/www/my_project/vendor/symfony/dotenv/Dotenv.php:95\nStack trace:\n#0 /var/www/my_project/vendor/symfony/dotenv/Dotenv.php(57): Symfony\Component\Dotenv\Dotenv->populate(Array)\n#1 /var/www/my_project/public/index.php(15): Symfony\Component\Dotenv\Dotenv->load('/var/www/rodage...')\n#2 {main}\n  thrown in /var/www/my_project/vendor/symfony/dotenv/Dotenv.php on line 95

This is my index.php (default index.php that you get when you create a project):

<?php

use App\Kernel;
use Symfony\Component\Debug\Debug;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\HttpFoundation\Request;

require __DIR__.'/../vendor/autoload.php';

// The check is to ensure we don't use .env in production
if (!isset($_SERVER['APP_ENV'])) {
    if (!class_exists(Dotenv::class)) {
        throw new \RuntimeException('APP_ENV environment variable is not defined. You need to define environment variables for configuration or add "symfony/dotenv" as a Composer dependency to load variables from a .env file.');
    }
    (new Dotenv())->load(__DIR__.'/../.env');
}

if ($_SERVER['APP_DEBUG'] ?? ('prod' !== ($_SERVER['APP_ENV'] ?? 'dev'))) {
    umask(0000);

    Debug::enable();
}

if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? false) {
    Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}

if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? false) {
    Request::setTrustedHosts(explode(',', $trustedHosts));
}

$kernel = new Kernel($_SERVER['APP_ENV'] ?? 'dev', $_SERVER['APP_DEBUG'] ?? ('prod' !== ($_SERVER['APP_ENV'] ?? 'dev')));
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

This is what I have in my composer.json:

"require": {
    "php": "^7.1.3",
    "symfony/asset": "^4.0",
    "symfony/console": "^4.0",
    "symfony/dotenv": "^4.0",
    "symfony/flex": "^1.0",
    "symfony/framework-bundle": "^4.0",
    "symfony/lts": "^4@dev",
    "symfony/twig-bundle": "^4.0",
    "symfony/web-server-bundle": "^4.0",
    "symfony/yaml": "^4.0"
},

These are the things that I tried:

-cache:clear

-composer update

-apache restart

I think that it something about environment variables, but not really sure...

Any suggestions?

Thank you all for your time!


问:
Error 287 on Send command after upgrade to Windows 10
I have Excel VBA code that generates an Outlook e-mail with an attachment.

This worked in Windows 8.1 but does not work in Windows 10. I have stepped through the macro, and it gets all the way to the end, generates the e-mail, then fails on the OutMail.Send command. The error is

Runtime error 287 - Application-defined or object-defined error

Here is the code.

```<code>Sub batchallocationemail()

'define email & pdf
Dim IsCreated As Boolean
Dim PdfFile As String, Title As String
Dim OutlApp As Object
Dim OutMail As Object

'
' print allocation Macro

'define worksheets
Dim ws As Worksheet
Set ws = Sheets("Caseworkers")
Dim ws2 As Worksheet
Set ws2 = Sheets("Allocation Sheet")
'define range
Dim NameRange As Range
Dim NameRange2 As Range
Dim x As Range
Dim z As Range
Set z = ws2.Range("B1")

Set NameRange = ws.Range("A1:C69")
Set NameRange2 = ws.Range("A2:A69")
Set NameRange3 = ws.Range("C2:C69")

'Selects name from list and pastes into allocation
ws.Select
NameRange.AutoFilter Field:=2, Criteria1:="In"
For Each x In NameRange2.SpecialCells(xlCellTypeVisible)
        x.Copy
        ws2.Select
        Range("B1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        ws2.Select
'CONVERTS ACTIVE SHEET TO PDF AND EMAILS IT
        ' Define Title
        Title = Range("B1").Value
        ' Define PDF filename
        Title = "Allocation Sheet for " & Range("B1").Value
        PdfFile = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\" & Title & ".pdf"
  ' Export activesheet as PDF
        With ActiveSheet
            .ExportAsFixedFormat Type:=xlTypePDF, Filename:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
        End With
' Use already open Outlook if possible
        On Error Resume Next
        Set OutlApp = GetObject(, "Outlook.Application")
        If Err Then
            Set OutlApp = CreateObject("Outlook.Application")
            IsCreated = True
        End If
        OutlApp.Visible = True
        On Error GoTo 0

' Prepare e-mail with PDF attachment
        Set OutMail = OutlApp.CreateItem(0)
        With OutMail

' Prepare e-mail
            OutMail.Subject = Title
            OutMail.To = x.Offset(0, 2).Value ' <-- Put email of the recipient here
            OutMail.CC = x.Offset(0, 3).Value ' <-- Put email of 'copy to' recipient here
            OutMail.Body = "Hello," & vbLf & vbLf _
            & "Please see your attached allocation sheet in PDF format." & vbLf & vbLf _
            & "Kind Regards," & vbLf _
            & Application.UserName & vbLf & vbLf
            OutMail.Attachments.Add PdfFile
        ' Try to send
            Application.Visible = True
            OutMail.Display
            OutMail.Send
        End With

    ' Quit Outlook if it was not already open
        If IsCreated Then OutlApp.Quit

    ' Release the memory of object variable
        Set OutMail = Nothing
        Set OutlApp = Nothing
    Next x

End Sub
</code>```

答: sorry about this, i think I have fixed it. I posted this earlier after looking through for hours last night but I seem to have got it. Instead of .Send i used Application.SendKeys "%s" which is a shortcut. This seems to send the e-mail properly. </p>

Body:
I have Excel VBA code that generates an Outlook e-mail with an attachment.

This worked in Windows 8.1 but does not work in Windows 10. I have stepped through the macro, and it gets all the way to the end, generates the e-mail, then fails on the OutMail.Send command. The error is

Runtime error 287 - Application-defined or object-defined error

Here is the code.

Sub batchallocationemail()

'define email & pdf
Dim IsCreated As Boolean
Dim PdfFile As String, Title As String
Dim OutlApp As Object
Dim OutMail As Object

'
' print allocation Macro

'define worksheets
Dim ws As Worksheet
Set ws = Sheets("Caseworkers")
Dim ws2 As Worksheet
Set ws2 = Sheets("Allocation Sheet")
'define range
Dim NameRange As Range
Dim NameRange2 As Range
Dim x As Range
Dim z As Range
Set z = ws2.Range("B1")

Set NameRange = ws.Range("A1:C69")
Set NameRange2 = ws.Range("A2:A69")
Set NameRange3 = ws.Range("C2:C69")

'Selects name from list and pastes into allocation
ws.Select
NameRange.AutoFilter Field:=2, Criteria1:="In"
For Each x In NameRange2.SpecialCells(xlCellTypeVisible)
        x.Copy
        ws2.Select
        Range("B1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        ws2.Select
'CONVERTS ACTIVE SHEET TO PDF AND EMAILS IT
        ' Define Title
        Title = Range("B1").Value
        ' Define PDF filename
        Title = "Allocation Sheet for " & Range("B1").Value
        PdfFile = CreateObject("WScript.Shell").SpecialFolders("Desktop") & "\" & Title & ".pdf"
  ' Export activesheet as PDF
        With ActiveSheet
            .ExportAsFixedFormat Type:=xlTypePDF, Filename:=PdfFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
        End With
' Use already open Outlook if possible
        On Error Resume Next
        Set OutlApp = GetObject(, "Outlook.Application")
        If Err Then
            Set OutlApp = CreateObject("Outlook.Application")
            IsCreated = True
        End If
        OutlApp.Visible = True
        On Error GoTo 0

' Prepare e-mail with PDF attachment
        Set OutMail = OutlApp.CreateItem(0)
        With OutMail

' Prepare e-mail
            OutMail.Subject = Title
            OutMail.To = x.Offset(0, 2).Value ' <-- Put email of the recipient here
            OutMail.CC = x.Offset(0, 3).Value ' <-- Put email of 'copy to' recipient here
            OutMail.Body = "Hello," & vbLf & vbLf _
            & "Please see your attached allocation sheet in PDF format." & vbLf & vbLf _
            & "Kind Regards," & vbLf _
            & Application.UserName & vbLf & vbLf
            OutMail.Attachments.Add PdfFile
        ' Try to send
            Application.Visible = True
            OutMail.Display
            OutMail.Send
        End With

    ' Quit Outlook if it was not already open
        If IsCreated Then OutlApp.Quit

    ' Release the memory of object variable
        Set OutMail = Nothing
        Set OutlApp = Nothing
    Next x

End Sub


问:
R: Install cplexAPI errors
I am trying to use cplexAPI in R. I am getting persistent errors. I am using Microsoft R Open 3.3.1 and have installed IBM ILOG CPLEX Optimization Studio Version: 12.7.0.0 on Windows 10. Here is what I have done, and what has resulted. I am going to go into painstaking detail on the hope that you see my error somewhere!

Unpacked the tar file to a folder on my desktop.

Edit the file: C:\Users\zejas\Desktop\cplexAPI\cplexAPI\src\Makevars.win to say:

    PKG_CPPFLAGS=-g -D_R_=1 -DUSE_R=1 -I"$C:\Program  Files\IBM\ILOG\CPLEX_Studio127\cplex\include"
    PKG_LIBS=-L"$C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\lib" -lm -lcplex1270

Microsoft put their own spin on the Reviron.site file. They put Rcmd_environ in: C:\Program Files\Microsoft\MRO-3.3.1\etc\Rcmd_environ
Within that file I added the bottom three lines:

    ## from R.sh
    R_SHARE_DIR=${R_HOME}/share
    R_INCLUDE_DIR=${R_HOME}/include
    R_DOC_DIR=${R_HOME}/doc
    R_ARCH=
    ## from Rcmd
    R_OSTYPE=windows
    TEXINPUTS=.;${TEXINPUTS};${R_SHARE_DIR}/texmf/tex/latex;
    BIBINPUTS=.;${BIBINPUTS};${R_SHARE_DIR}/texmf/bibtex/bib;
    BSTINPUTS=.;${BSTINPUTS};${R_SHARE_DIR}/texmf/bibtex/bst;
    ## from etc/Renviron
    # R_PLATFORM='i386-pc-mingw32'
    R_PAPERSIZE_USER=${R_PAPERSIZE}
    R_PAPERSIZE=${R_PAPERSIZE-'a4'}
    # for Rd2dpf, reference manual
    R_RD4PDF=${R_RD4PDF-'times,inconsolata,hyper'}
    ## used for options("texi2dvi")
    # R_TEXI2DVICMD=${R_TEXI2DVICMD-${TEXI2DVI-'texi2dvi'}}
    ## used by INSTALL, check, build
    R_GZIPCMD=${R_GZIPCMD-'gzip'}
    ## Default zip/unzip commands
    R_UNZIPCMD=${R_UNZIPCMD-'unzip'}
    R_ZIPCMD=${R_ZIPCMD-'zip'}
    R_BZIPCMD=${R_BZIPCMD-'bzip2'}
    ## Default browser
    # R_BROWSER=${R_BROWSER-'open'}
    ## Default editor
    # EDITOR=${EDITOR-${VISUAL-vi}}
    ## Default pager
    # PAGER=${PAGER-''}
    ## Default PDF viewer
    # R_PDFVIEWER=${R_PDFVIEWER-'open'}
    # MAKE=${MAKE-make}
    SED=${SED-sed}
    #
    CPLEX_STUDIO_DIR=C:/Program Files/IBM/ILOG/CPLEX_Studio127
    CPLEX_STUDIO_LIB=C:/Program Files/IBM/ILOG/CPLEX_Studio127/cplex/bin/x64_win64

In Environment Variables System Variables Path I had already added:

    %CPLEX_STUDIO_BINARIES127%;
    C:\Program Files (x86)\Intel\OpenCL SDK\6.1\bin\x64;
    C:\Program Files (x86)\Intel\OpenCL SDK\6.1\bin\x86;
    C:\Program Files (x86)\Intel\OpenCL SDK\6.1\bin\Pin;
    C:\Program Files (x86)\Intel\OpenCL SDK\6.1\bin\GTPin;
    C:\ProgramData\Oracle\Java\javapath;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin;
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp;
    C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;
    C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;
    C:\Windows\System32\WindowsPowerShell\v1.0\;
    C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;
    C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;
    C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;
    C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;
    C:\Program Files (x86)\Skype\Phone\;
    C:\Program Files\MATLAB\R2016b\bin;
    C:\Program Files\MATLAB\R2016a\bin;
    C:\Program Files\Microsoft\MRO-3.3.1\bin\x64;
    C:\Users\zejas\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;
    C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;
    C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;
    C:\WINDOWS\system32;C:\WINDOWS;
    C:\WINDOWS\System32\Wbem;
    C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
    C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;
    C:\Program Files\Git\cmd;
    C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\bin\x64_win64;
    C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include;
    C:\Rtools\bin

I rebuild the package:

    C:\Users\zejas>R CMD build --no-build-vignettes --no-manual  --md5 C:\Users\zejas\Desktop\cplexAPI\cplexAPI
    * checking for file 'C:\Users\zejas\Desktop\cplexAPI\cplexAPI/DESCRIPTION' ... OK
    * preparing 'cplexAPI':
    * checking DESCRIPTION meta-information ... OK
    * cleaning src
    * checking vignette meta-information ... OK
    * checking for LF line-endings in source and make files
    * checking for empty or unneeded directories
    * adding MD5 file
    * building 'cplexAPI_1.3.2.tar.gz'
    Warning: file 'cplexAPI/cleanup' did not have execute permissions: corrected
    Warning: file 'cplexAPI/configure' did not have execute permissions: corrected

I attempt install of the package:

    C:\Users\zejas>"C:\Program Files\Microsoft\MRO-3.3.1\bin\x64\R.exe" CMD  INSTALL --build --no-multiarch ./cplexAPI.tar.gz
    * installing to library 'C:/Users/zejas/Documents/R/win-library/3.3'
    * installing *source* package 'cplexAPI' ...
    ** package 'cplexAPI' successfully unpacked and MD5 sums checked
    ** libs
    c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include"  -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I":\Program  Files\IBM\ILOG\CPLEX_Studio127\cplex\include"    -I"C:/swarm/workspace/External- R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c  cplexAPI.c -o cplexAPI.o
    In file included from cplexAPI.h:26:0, from cplexAPI.c:26:
    cplexR.h:50:27: fatal error: ilcplex/cplex.h: No such file or directory
    #include <ilcplex/cplex.h>
                             ^
    compilation terminated.
    make: *** [cplexAPI.o] Error 1
    Warning: running command 'make -f "Makevars.win" -f    "C:/PROGRA~1/MICROS~1/MRO-33~1.1/etc/x64/Makeconf" -f "C:/PROGRA~1/MICROS~1/MRO-  33~1.1/share/make/winshlib.mk" SHLIB="cplexAPI.dll" WIN=64 TCLBIN=64   OBJECTS="cplexAPI.o cplexR.o cplex_checkAPI.o cplex_longparamAPI.o init.o"' had   status 2
    ERROR: compilation failed for package 'cplexAPI'
    * removing 'C:/Users/zejas/Documents/R/win-library/3.3/cplexAPI'

There absolutely is a cplex.h file in that directory!

```<code>C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include\ilcplex>dir

 Volume in drive C is OS
 Volume Serial Number is 0A1B-3F26
 Directory of C:\Program    Files\IBM\ILOG\CPLEX_Studio127\cplex\include\ilcplex
01/09/2017  10:43 AM    <DIR>          .
01/09/2017  10:43 AM    <DIR>          ..
01/09/2017  10:43 AM             2,499 annotation.xsd
01/09/2017  10:43 AM            72,321 cplex.h
01/09/2017  10:43 AM             6,429 cplexcheck.h
01/09/2017  10:43 AM             1,703 cplexdistmip.h
01/09/2017  10:43 AM             1,857 cplexdistmipl.h
01/09/2017  10:43 AM             1,857 cplexdistmips.h
01/09/2017  10:43 AM             2,569 cplexdistmipx.h
01/09/2017  10:43 AM            76,659 cplexl.h
01/09/2017  10:43 AM             2,826 cplexremote.h
01/09/2017  10:43 AM             2,944 cplexremotel.h
01/09/2017  10:43 AM           111,312 cplexremotemaster.h
01/09/2017  10:43 AM           107,895 cplexremotemasterl.h
01/09/2017  10:43 AM           107,777 cplexremotemasters.h
01/09/2017  10:43 AM           220,496 cplexremotemasterx.h
01/09/2017  10:43 AM             2,944 cplexremotes.h
01/09/2017  10:43 AM             3,379 cplexremoteworker.h
01/09/2017  10:43 AM             3,505 cplexremoteworkerl.h
01/09/2017  10:43 AM             3,511 cplexremoteworkers.h
01/09/2017  10:43 AM             4,554 cplexremoteworkerx.h
01/09/2017  10:43 AM             3,289 cplexremotex.h
01/09/2017  10:43 AM            76,354 cplexs.h
01/09/2017  10:43 AM           119,712 cplexx.h
01/09/2017  10:43 AM            70,061 cpxconst.h
01/09/2017  10:43 AM               675 ilm.h
01/09/2017  10:43 AM             7,158 ilocarray.h
01/09/2017  10:43 AM           186,959 ilocplex.h
01/09/2017  10:43 AM           205,973 ilocplexi.h
01/09/2017  10:43 AM            13,174 iloextrmgr.h
01/09/2017  10:43 AM            13,496 ilogoals.h
01/09/2017  10:43 AM            15,241 iloparam.h
01/09/2017  10:43 AM             5,705 solution.xsd
01/09/2017  10:43 AM             5,504 solution.xsl
01/09/2017  10:43 AM             1,397 vmc.dtd
01/09/2017  10:43 AM             2,837 vmc.xsd
34 File(s)      1,464,572 bytes
2 Dir(s)  333,053,566,976 bytes free
</code>```

Any ideas?

Update with input from @c0bra and @rkersh

I update Makevars.win:

```<code>PKG_CPPFLAGS=-g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include"
PKG_LIBS=-L"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\lib" -lm -lcplex1270
</code>```

Rebuild at the command line:

```<code>C:\Users\zejas>R CMD build --no-build-vignettes --no-manual  --md5     C:\Users\zejas\Desktop\cplexAPI\cplexAPI
* checking for file 'C:\Users\zejas\Desktop\cplexAPI\cplexAPI/DESCRIPTION' ... OK
* preparing 'cplexAPI':
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking vignette meta-information ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* adding MD5 file
* building 'cplexAPI_1.3.2.tar.gz'
Warning: file 'cplexAPI/cleanup' did not have execute permissions: corrected
Warning: file 'cplexAPI/configure' did not have execute permissions: corrected
</code>```

I attempt to install from the command line:

```<code>C:\Users\zejas>"C:\Program Files\Microsoft\MRO-3.3.1\bin\x64\R.exe" CMD  INSTALL --build --no-multiarch .\cplexAPI_1.3.2.tar.gz
* installing to library 'C:/Users/zejas/Documents/R/win-library/3.3'
* installing *source* package 'cplexAPI' ...
** package 'cplexAPI' successfully unpacked and MD5 sums checked
** libs
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplexAPI.c -o cplexAPI.o
cplexAPI.c: In function 'addChannel':
cplexAPI.c:5198:5: warning: implicit declaration of function 'CPXaddchannel' [-Wimplicit-function-declaration]
     newch = CPXaddchannel(R_ExternalPtrAddr(env));
     ^
cplexAPI.c:5198:11: warning: assignment makes pointer from integer without a cast
     newch = CPXaddchannel(R_ExternalPtrAddr(env));
           ^
cplexAPI.c: In function 'delChannel':
cplexAPI.c:5234:5: warning: implicit declaration of function 'CPXdelchannel' [-Wimplicit-function-declaration]
     CPXdelchannel(R_ExternalPtrAddr(env), &delch);
     ^
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplexR.c -o cplexR.o
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplex_checkAPI.c -o cplex_checkAPI.o
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplex_longparamAPI.c -o cplex_longparamAPI.o
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c init.c -o init.o
c:/Rtools/mingw_64/bin/gcc -m64 -shared -s -static-libgcc -o cplexAPI.dll tmp.def cplexAPI.o cplexR.o cplex_checkAPI.o cplex_longparamAPI.o init.o -LC:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\lib -lm -lcplex1270 -LC:/swarm/workspace/External-R-3.3.1/vendor/extsoft/lib/x64 -LC:/swarm/workspace/External-R-3.3.1/vendor/extsoft/lib -LC:/PROGRA~1/MICROS~1/MRO-33~1.1/bin/x64 -lR
C:/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lcplex1270
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'cplexAPI'
* removing 'C:/Users/zejas/Documents/R/win-library/3.3/cplexAPI'
</code>```

I edit Makevars.win

```<code>PKG_CPPFLAGS=-g -D_R_=1 -DUSE_R=1 -I"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include"
PKG_LIBS=-L"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include/lib" -lm -lcplex1270
</code>```

I rebuild:

```<code>C:\Users\zejas>R CMD build --no-build-vignettes --no-manual  --md5 C:\Users\zejas\Desktop\cplexAPI\cplexAPI
* checking for file 'C:\Users\zejas\Desktop\cplexAPI\cplexAPI/DESCRIPTION' ... OK
* preparing 'cplexAPI':
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking vignette meta-information ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* adding MD5 file
* building 'cplexAPI_1.3.2.tar.gz'
Warning: file 'cplexAPI/cleanup' did not have execute permissions: corrected
Warning: file 'cplexAPI/configure' did not have execute permissions: corrected
</code>```

I attempt to install:

```<code>C:\Users\zejas>"C:\Program Files\Microsoft\MRO-3.3.1\bin\x64\R.exe" CMD  INSTALL --build --no-multiarch .\cplexAPI_1.3.2.tar.gz
* installing to library 'C:/Users/zejas/Documents/R/win-library/3.3'
* installing *source* package 'cplexAPI' ...
** package 'cplexAPI' successfully unpacked and MD5 sums checked
** libs
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplexAPI.c -o cplexAPI.o
cplexAPI.c: In function 'addChannel':
cplexAPI.c:5198:5: warning: implicit declaration of function 'CPXaddchannel' [-Wimplicit-function-declaration]
     newch = CPXaddchannel(R_ExternalPtrAddr(env));
     ^
cplexAPI.c:5198:11: warning: assignment makes pointer from integer without a cast
     newch = CPXaddchannel(R_ExternalPtrAddr(env));
           ^
cplexAPI.c: In function 'delChannel':
cplexAPI.c:5234:5: warning: implicit declaration of function 'CPXdelchannel' [-Wimplicit-function-declaration]
     CPXdelchannel(R_ExternalPtrAddr(env), &delch);
     ^
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplexR.c -o cplexR.o
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplex_checkAPI.c -o cplex_checkAPI.o
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplex_longparamAPI.c -o cplex_longparamAPI.o
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c init.c -o init.o
c:/Rtools/mingw_64/bin/gcc -m64 -shared -s -static-libgcc -o cplexAPI.dll tmp.def cplexAPI.o cplexR.o cplex_checkAPI.o cplex_longparamAPI.o init.o -LC:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include/lib -lm -lcplex1270 -LC:/swarm/workspace/External-R-3.3.1/vendor/extsoft/lib/x64 -LC:/swarm/workspace/External-R-3.3.1/vendor/extsoft/lib -LC:/PROGRA~1/MICROS~1/MRO-33~1.1/bin/x64 -lR
C:/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lcplex1270
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'cplexAPI'
* removing 'C:/Users/zejas/Documents/R/win-library/3.3/cplexAPI'
</code>```

Those are new errors!

答:
I was facing similar problem while integrating CPLEX with R, and installing the cplexAPI package, see https://cran.r-project.org/web/packages/cplexAPI/
there were few mistakes that I was doing, first of all, the problem arises because R does not know where IBM CPLEX is installed, so you have to manually change the file Makevars.win in the cplexAPI_1.3.3.tar.gz package that is downloaded while you were trying to install cplexAPI from rstudio GUI.
look for following codes:

```<code>PKG_CPPFLAGS=-g -D_R_=1 -DUSE_R=1 -I"${CPLEX_STUDIO_DIR}\cplex\include"
PKG_LIBS=-L"${CPLEX_STUDIO_LIB}" -lm -lcplex1261
</code>```

two thing that you need to check is -L"${CPLEX_STUDIO_LIB}" is replaced by in my case, -L"C:/Program Files/IBM/ILOG/CPLEX_Studio1271/cplex/bin/x64_win64" (see bin/x64_win64) , replace $ too

second inside the folder x64_win64, look for cplex12**.dll file, this the file where -lcplex1261 is pointing to, here manually change -lcplex1261 to whatever your file name is (in my case it was cplex1271.dll, so I changed -lcplex1261 to -lcplex1271,

similarly ${CPLEX_STUDIO_DIR} must be replaced by C:/Program Files/IBM/ILOG/CPLEX_Studio1271 (in my case).

After this, follow the instruction given in https://www.r-bloggers.com/using-cplex-in-r-installing-cplexapi-in-windows-10/,
essentially use the following command (from command lines) to repackage and install cplexAPI_1.3.3.tar.gz (make sure you have Rtools installed, and make sure environment variables have PATH pointing to installation files of R, essentially taking to R.exe and Rcmd.exe for the commands to run), and

```<code>R CMD build --no-build-vignettes --no-manual --md5 C:\Users{computer name here}\Desktop\cplexAPI

R CMD INSTALL --build --no-multiarch .\cplexAPI_1.3.3.tar.gz
</code>```

Title: R: Install cplexAPI errors

Body:
I am trying to use cplexAPI in R. I am getting persistent errors. I am using Microsoft R Open 3.3.1 and have installed IBM ILOG CPLEX Optimization Studio Version: 12.7.0.0 on Windows 10. Here is what I have done, and what has resulted. I am going to go into painstaking detail on the hope that you see my error somewhere!

Unpacked the tar file to a folder on my desktop.

Edit the file: C:\Users\zejas\Desktop\cplexAPI\cplexAPI\src\Makevars.win to say:

    PKG_CPPFLAGS=-g -D_R_=1 -DUSE_R=1 -I"$C:\Program  Files\IBM\ILOG\CPLEX_Studio127\cplex\include"
    PKG_LIBS=-L"$C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\lib" -lm -lcplex1270

Microsoft put their own spin on the Reviron.site file. They put Rcmd_environ in: C:\Program Files\Microsoft\MRO-3.3.1\etc\Rcmd_environ
Within that file I added the bottom three lines:

    ## from R.sh
    R_SHARE_DIR=${R_HOME}/share
    R_INCLUDE_DIR=${R_HOME}/include
    R_DOC_DIR=${R_HOME}/doc
    R_ARCH=
    ## from Rcmd
    R_OSTYPE=windows
    TEXINPUTS=.;${TEXINPUTS};${R_SHARE_DIR}/texmf/tex/latex;
    BIBINPUTS=.;${BIBINPUTS};${R_SHARE_DIR}/texmf/bibtex/bib;
    BSTINPUTS=.;${BSTINPUTS};${R_SHARE_DIR}/texmf/bibtex/bst;
    ## from etc/Renviron
    # R_PLATFORM='i386-pc-mingw32'
    R_PAPERSIZE_USER=${R_PAPERSIZE}
    R_PAPERSIZE=${R_PAPERSIZE-'a4'}
    # for Rd2dpf, reference manual
    R_RD4PDF=${R_RD4PDF-'times,inconsolata,hyper'}
    ## used for options("texi2dvi")
    # R_TEXI2DVICMD=${R_TEXI2DVICMD-${TEXI2DVI-'texi2dvi'}}
    ## used by INSTALL, check, build
    R_GZIPCMD=${R_GZIPCMD-'gzip'}
    ## Default zip/unzip commands
    R_UNZIPCMD=${R_UNZIPCMD-'unzip'}
    R_ZIPCMD=${R_ZIPCMD-'zip'}
    R_BZIPCMD=${R_BZIPCMD-'bzip2'}
    ## Default browser
    # R_BROWSER=${R_BROWSER-'open'}
    ## Default editor
    # EDITOR=${EDITOR-${VISUAL-vi}}
    ## Default pager
    # PAGER=${PAGER-''}
    ## Default PDF viewer
    # R_PDFVIEWER=${R_PDFVIEWER-'open'}
    # MAKE=${MAKE-make}
    SED=${SED-sed}
    #
    CPLEX_STUDIO_DIR=C:/Program Files/IBM/ILOG/CPLEX_Studio127
    CPLEX_STUDIO_LIB=C:/Program Files/IBM/ILOG/CPLEX_Studio127/cplex/bin/x64_win64

In Environment Variables System Variables Path I had already added:

    %CPLEX_STUDIO_BINARIES127%;
    C:\Program Files (x86)\Intel\OpenCL SDK\6.1\bin\x64;
    C:\Program Files (x86)\Intel\OpenCL SDK\6.1\bin\x86;
    C:\Program Files (x86)\Intel\OpenCL SDK\6.1\bin\Pin;
    C:\Program Files (x86)\Intel\OpenCL SDK\6.1\bin\GTPin;
    C:\ProgramData\Oracle\Java\javapath;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin;
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp;
    C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;
    C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;
    C:\Windows\System32\WindowsPowerShell\v1.0\;
    C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;
    C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;
    C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;
    C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;
    C:\Program Files (x86)\Skype\Phone\;
    C:\Program Files\MATLAB\R2016b\bin;
    C:\Program Files\MATLAB\R2016a\bin;
    C:\Program Files\Microsoft\MRO-3.3.1\bin\x64;
    C:\Users\zejas\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;
    C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;
    C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;
    C:\WINDOWS\system32;C:\WINDOWS;
    C:\WINDOWS\System32\Wbem;
    C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
    C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;
    C:\Program Files\Git\cmd;
    C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\bin\x64_win64;
    C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include;
    C:\Rtools\bin

I rebuild the package:

    C:\Users\zejas>R CMD build --no-build-vignettes --no-manual  --md5 C:\Users\zejas\Desktop\cplexAPI\cplexAPI
    * checking for file 'C:\Users\zejas\Desktop\cplexAPI\cplexAPI/DESCRIPTION' ... OK
    * preparing 'cplexAPI':
    * checking DESCRIPTION meta-information ... OK
    * cleaning src
    * checking vignette meta-information ... OK
    * checking for LF line-endings in source and make files
    * checking for empty or unneeded directories
    * adding MD5 file
    * building 'cplexAPI_1.3.2.tar.gz'
    Warning: file 'cplexAPI/cleanup' did not have execute permissions: corrected
    Warning: file 'cplexAPI/configure' did not have execute permissions: corrected

I attempt install of the package:

    C:\Users\zejas>"C:\Program Files\Microsoft\MRO-3.3.1\bin\x64\R.exe" CMD  INSTALL --build --no-multiarch ./cplexAPI.tar.gz
    * installing to library 'C:/Users/zejas/Documents/R/win-library/3.3'
    * installing *source* package 'cplexAPI' ...
    ** package 'cplexAPI' successfully unpacked and MD5 sums checked
    ** libs
    c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include"  -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I":\Program  Files\IBM\ILOG\CPLEX_Studio127\cplex\include"    -I"C:/swarm/workspace/External- R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c  cplexAPI.c -o cplexAPI.o
    In file included from cplexAPI.h:26:0, from cplexAPI.c:26:
    cplexR.h:50:27: fatal error: ilcplex/cplex.h: No such file or directory
    #include <ilcplex/cplex.h>
                             ^
    compilation terminated.
    make: *** [cplexAPI.o] Error 1
    Warning: running command 'make -f "Makevars.win" -f    "C:/PROGRA~1/MICROS~1/MRO-33~1.1/etc/x64/Makeconf" -f "C:/PROGRA~1/MICROS~1/MRO-  33~1.1/share/make/winshlib.mk" SHLIB="cplexAPI.dll" WIN=64 TCLBIN=64   OBJECTS="cplexAPI.o cplexR.o cplex_checkAPI.o cplex_longparamAPI.o init.o"' had   status 2
    ERROR: compilation failed for package 'cplexAPI'
    * removing 'C:/Users/zejas/Documents/R/win-library/3.3/cplexAPI'

There absolutely is a cplex.h file in that directory!

C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include\ilcplex>dir

 Volume in drive C is OS
 Volume Serial Number is 0A1B-3F26
 Directory of C:\Program    Files\IBM\ILOG\CPLEX_Studio127\cplex\include\ilcplex
01/09/2017  10:43 AM    <DIR>          .
01/09/2017  10:43 AM    <DIR>          ..
01/09/2017  10:43 AM             2,499 annotation.xsd
01/09/2017  10:43 AM            72,321 cplex.h
01/09/2017  10:43 AM             6,429 cplexcheck.h
01/09/2017  10:43 AM             1,703 cplexdistmip.h
01/09/2017  10:43 AM             1,857 cplexdistmipl.h
01/09/2017  10:43 AM             1,857 cplexdistmips.h
01/09/2017  10:43 AM             2,569 cplexdistmipx.h
01/09/2017  10:43 AM            76,659 cplexl.h
01/09/2017  10:43 AM             2,826 cplexremote.h
01/09/2017  10:43 AM             2,944 cplexremotel.h
01/09/2017  10:43 AM           111,312 cplexremotemaster.h
01/09/2017  10:43 AM           107,895 cplexremotemasterl.h
01/09/2017  10:43 AM           107,777 cplexremotemasters.h
01/09/2017  10:43 AM           220,496 cplexremotemasterx.h
01/09/2017  10:43 AM             2,944 cplexremotes.h
01/09/2017  10:43 AM             3,379 cplexremoteworker.h
01/09/2017  10:43 AM             3,505 cplexremoteworkerl.h
01/09/2017  10:43 AM             3,511 cplexremoteworkers.h
01/09/2017  10:43 AM             4,554 cplexremoteworkerx.h
01/09/2017  10:43 AM             3,289 cplexremotex.h
01/09/2017  10:43 AM            76,354 cplexs.h
01/09/2017  10:43 AM           119,712 cplexx.h
01/09/2017  10:43 AM            70,061 cpxconst.h
01/09/2017  10:43 AM               675 ilm.h
01/09/2017  10:43 AM             7,158 ilocarray.h
01/09/2017  10:43 AM           186,959 ilocplex.h
01/09/2017  10:43 AM           205,973 ilocplexi.h
01/09/2017  10:43 AM            13,174 iloextrmgr.h
01/09/2017  10:43 AM            13,496 ilogoals.h
01/09/2017  10:43 AM            15,241 iloparam.h
01/09/2017  10:43 AM             5,705 solution.xsd
01/09/2017  10:43 AM             5,504 solution.xsl
01/09/2017  10:43 AM             1,397 vmc.dtd
01/09/2017  10:43 AM             2,837 vmc.xsd
34 File(s)      1,464,572 bytes
2 Dir(s)  333,053,566,976 bytes free

Any ideas?

Update with input from @c0bra and @rkersh

I update Makevars.win:

PKG_CPPFLAGS=-g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include"
PKG_LIBS=-L"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\lib" -lm -lcplex1270

Rebuild at the command line:

C:\Users\zejas>R CMD build --no-build-vignettes --no-manual  --md5     C:\Users\zejas\Desktop\cplexAPI\cplexAPI
* checking for file 'C:\Users\zejas\Desktop\cplexAPI\cplexAPI/DESCRIPTION' ... OK
* preparing 'cplexAPI':
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking vignette meta-information ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* adding MD5 file
* building 'cplexAPI_1.3.2.tar.gz'
Warning: file 'cplexAPI/cleanup' did not have execute permissions: corrected
Warning: file 'cplexAPI/configure' did not have execute permissions: corrected

I attempt to install from the command line:

C:\Users\zejas>"C:\Program Files\Microsoft\MRO-3.3.1\bin\x64\R.exe" CMD  INSTALL --build --no-multiarch .\cplexAPI_1.3.2.tar.gz
* installing to library 'C:/Users/zejas/Documents/R/win-library/3.3'
* installing *source* package 'cplexAPI' ...
** package 'cplexAPI' successfully unpacked and MD5 sums checked
** libs
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplexAPI.c -o cplexAPI.o
cplexAPI.c: In function 'addChannel':
cplexAPI.c:5198:5: warning: implicit declaration of function 'CPXaddchannel' [-Wimplicit-function-declaration]
     newch = CPXaddchannel(R_ExternalPtrAddr(env));
     ^
cplexAPI.c:5198:11: warning: assignment makes pointer from integer without a cast
     newch = CPXaddchannel(R_ExternalPtrAddr(env));
           ^
cplexAPI.c: In function 'delChannel':
cplexAPI.c:5234:5: warning: implicit declaration of function 'CPXdelchannel' [-Wimplicit-function-declaration]
     CPXdelchannel(R_ExternalPtrAddr(env), &delch);
     ^
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplexR.c -o cplexR.o
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplex_checkAPI.c -o cplex_checkAPI.o
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplex_longparamAPI.c -o cplex_longparamAPI.o
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c init.c -o init.o
c:/Rtools/mingw_64/bin/gcc -m64 -shared -s -static-libgcc -o cplexAPI.dll tmp.def cplexAPI.o cplexR.o cplex_checkAPI.o cplex_longparamAPI.o init.o -LC:\Program Files\IBM\ILOG\CPLEX_Studio127\cplex\lib -lm -lcplex1270 -LC:/swarm/workspace/External-R-3.3.1/vendor/extsoft/lib/x64 -LC:/swarm/workspace/External-R-3.3.1/vendor/extsoft/lib -LC:/PROGRA~1/MICROS~1/MRO-33~1.1/bin/x64 -lR
C:/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lcplex1270
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'cplexAPI'
* removing 'C:/Users/zejas/Documents/R/win-library/3.3/cplexAPI'

I edit Makevars.win

PKG_CPPFLAGS=-g -D_R_=1 -DUSE_R=1 -I"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include"
PKG_LIBS=-L"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include/lib" -lm -lcplex1270

I rebuild:

C:\Users\zejas>R CMD build --no-build-vignettes --no-manual  --md5 C:\Users\zejas\Desktop\cplexAPI\cplexAPI
* checking for file 'C:\Users\zejas\Desktop\cplexAPI\cplexAPI/DESCRIPTION' ... OK
* preparing 'cplexAPI':
* checking DESCRIPTION meta-information ... OK
* cleaning src
* checking vignette meta-information ... OK
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* adding MD5 file
* building 'cplexAPI_1.3.2.tar.gz'
Warning: file 'cplexAPI/cleanup' did not have execute permissions: corrected
Warning: file 'cplexAPI/configure' did not have execute permissions: corrected

I attempt to install:

C:\Users\zejas>"C:\Program Files\Microsoft\MRO-3.3.1\bin\x64\R.exe" CMD  INSTALL --build --no-multiarch .\cplexAPI_1.3.2.tar.gz
* installing to library 'C:/Users/zejas/Documents/R/win-library/3.3'
* installing *source* package 'cplexAPI' ...
** package 'cplexAPI' successfully unpacked and MD5 sums checked
** libs
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplexAPI.c -o cplexAPI.o
cplexAPI.c: In function 'addChannel':
cplexAPI.c:5198:5: warning: implicit declaration of function 'CPXaddchannel' [-Wimplicit-function-declaration]
     newch = CPXaddchannel(R_ExternalPtrAddr(env));
     ^
cplexAPI.c:5198:11: warning: assignment makes pointer from integer without a cast
     newch = CPXaddchannel(R_ExternalPtrAddr(env));
           ^
cplexAPI.c: In function 'delChannel':
cplexAPI.c:5234:5: warning: implicit declaration of function 'CPXdelchannel' [-Wimplicit-function-declaration]
     CPXdelchannel(R_ExternalPtrAddr(env), &delch);
     ^
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplexR.c -o cplexR.o
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplex_checkAPI.c -o cplex_checkAPI.o
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c cplex_longparamAPI.c -o cplex_longparamAPI.o
c:/Rtools/mingw_64/bin/gcc -m64 -I"C:/PROGRA~1/MICROS~1/MRO-33~1.1/include" -DNDEBUG -g -D_R_=1 -DUSE_R=1 -I"C:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include"    -I"C:/swarm/workspace/External-R-3.3.1/vendor/extsoft/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c init.c -o init.o
c:/Rtools/mingw_64/bin/gcc -m64 -shared -s -static-libgcc -o cplexAPI.dll tmp.def cplexAPI.o cplexR.o cplex_checkAPI.o cplex_longparamAPI.o init.o -LC:/PROGRA~1/IBM/ILOG/CPLEX_Studio127/cplex/include/lib -lm -lcplex1270 -LC:/swarm/workspace/External-R-3.3.1/vendor/extsoft/lib/x64 -LC:/swarm/workspace/External-R-3.3.1/vendor/extsoft/lib -LC:/PROGRA~1/MICROS~1/MRO-33~1.1/bin/x64 -lR
C:/Rtools/mingw_64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.3/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lcplex1270
collect2.exe: error: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'cplexAPI'
* removing 'C:/Users/zejas/Documents/R/win-library/3.3/cplexAPI'

Those are new errors!

Body:
I was facing similar problem while integrating CPLEX with R, and installing the cplexAPI package, see https://cran.r-project.org/web/packages/cplexAPI/
there were few mistakes that I was doing, first of all, the problem arises because R does not know where IBM CPLEX is installed, so you have to manually change the file Makevars.win in the cplexAPI_1.3.3.tar.gz package that is downloaded while you were trying to install cplexAPI from rstudio GUI.
look for following codes:

PKG_CPPFLAGS=-g -D_R_=1 -DUSE_R=1 -I"${CPLEX_STUDIO_DIR}\cplex\include"
PKG_LIBS=-L"${CPLEX_STUDIO_LIB}" -lm -lcplex1261

two thing that you need to check is -L"${CPLEX_STUDIO_LIB}" is replaced by in my case, -L"C:/Program Files/IBM/ILOG/CPLEX_Studio1271/cplex/bin/x64_win64" (see bin/x64_win64) , replace $ too

second inside the folder x64_win64, look for cplex12**.dll file, this the file where -lcplex1261 is pointing to, here manually change -lcplex1261 to whatever your file name is (in my case it was cplex1271.dll, so I changed -lcplex1261 to -lcplex1271,

similarly ${CPLEX_STUDIO_DIR} must be replaced by C:/Program Files/IBM/ILOG/CPLEX_Studio1271 (in my case).

After this, follow the instruction given in https://www.r-bloggers.com/using-cplex-in-r-installing-cplexapi-in-windows-10/,
essentially use the following command (from command lines) to repackage and install cplexAPI_1.3.3.tar.gz (make sure you have Rtools installed, and make sure environment variables have PATH pointing to installation files of R, essentially taking to R.exe and Rcmd.exe for the commands to run), and

R CMD build --no-build-vignettes --no-manual --md5 C:\Users{computer name here}\Desktop\cplexAPI

R CMD INSTALL --build --no-multiarch .\cplexAPI_1.3.3.tar.gz


问:
extract hours and seconds from POSIXct for plotting purposes in R
Suppose I have the following data.frame foo

```<code>           start.time duration
1 2012-02-06 15:47:00      1
2 2012-02-06 15:02:00      2
3 2012-02-22 10:08:00      3
4 2012-02-22 09:32:00      4
5 2012-03-21 13:47:00      5
</code>```

And class(foo$start.time) returns

```<code>[1] "POSIXct" "POSIXt"
</code>```

I'd like to create a plot of foo$duration v. foo$start.time.  In my scenario, I'm only interested in the time of day rather than the actual day of the year.  How does one go about extracting the time of day as hours:seconds from POSIXct class of vector?

答:
Lubridate doesn't handle time of day data, so Hadley recommends the hms package for this type of data. Something like this would work:

```<code>library(lubridate)
foo <- data.frame(start.time = parse_datetime(c("2012-02-06 15:47:00",
                                 "2012-02-06 15:02:00",
                                 "2012-02-22 10:08:00")),
                  duration   = c(1,2,3))

foo<-foo %>% mutate(time_of_day=hms::hms(second(start.time),minute(start.time),hour(start.time)))
</code>```

Watch out for 2 potential issues - 1) lubridate has a different function called hms and 2) hms::hms takes the arguments in the opposite order to that suggested by its name (so that just seconds may be supplied)

Body:
Suppose I have the following data.frame foo

           start.time duration
1 2012-02-06 15:47:00      1
2 2012-02-06 15:02:00      2
3 2012-02-22 10:08:00      3
4 2012-02-22 09:32:00      4
5 2012-03-21 13:47:00      5

And class(foo$start.time) returns

[1] "POSIXct" "POSIXt"

I'd like to create a plot of foo$duration v. foo$start.time.  In my scenario, I'm only interested in the time of day rather than the actual day of the year.  How does one go about extracting the time of day as hours:seconds from POSIXct class of vector?

Body:
Lubridate doesn't handle time of day data, so Hadley recommends the hms package for this type of data. Something like this would work:

library(lubridate)
foo <- data.frame(start.time = parse_datetime(c("2012-02-06 15:47:00",
                                 "2012-02-06 15:02:00",
                                 "2012-02-22 10:08:00")),
                  duration   = c(1,2,3))

foo<-foo %>% mutate(time_of_day=hms::hms(second(start.time),minute(start.time),hour(start.time)))

Watch out for 2 potential issues - 1) lubridate has a different function called hms and 2) hms::hms takes the arguments in the opposite order to that suggested by its name (so that just seconds may be supplied)


问:
Android NDK, two Static Libraries and Linking
I started off creating libraries as shared libraries, but I considered it would be more efficient to create one shared libraries and the rest static. When it was all shared, it compiled and linked fine, but moving to static, I get on linking "undefined reference".

Edit: I build all the libraries in one Android.mk

Android.mk:

```<code>MY_LOCAL_PATH := $(call my-dir)
MY_LOCAL_CFLAGS := -DDEBUG

TARGET_PLATFORM := 'android-4'

LOCAL_PATH := $(MY_LOCAL_PATH)/../../Base

include $(CLEAR_VARS)

LOCAL_MODULE     := Base
LOCAL_SRC_FILES  := <Base src files>
include $(BUILD_STATIC_LIBRARY)

MY_LOCAL_STATIC_LIBRARIES := Base

MY_LOCAL_C_INCLUDES := $(MY_LOCAL_PATH)/../../Base

LOCAL_PATH := $(MY_LOCAL_PATH)/../../Framework

include $(CLEAR_VARS)

LOCAL_MODULE     := Framework
LOCAL_C_INCLUDES := $(MY_LOCAL_C_INCLUDES)
LOCAL_SRC_FILES  := <Framework src files>
LOCAL_CFLAGS := $(MY_LOCAL_CFLAGS)

include $(BUILD_STATIC_LIBRARY)

MY_LOCAL_STATIC_LIBRARIES += Framework

MY_LOCAL_C_INCLUDES += $(MY_LOCAL_PATH)/../../Framework

LOCAL_PATH := $(MY_LOCAL_PATH)/Graphics

include $(CLEAR_VARS)

LOCAL_MODULE    := Graphics
LOCAL_SRC_FILES := <Graphics src files>
LOCAL_EXPORT_LDLIBS := -lGLESv1_CM
LOCAL_CFLAGS := $(MY_LOCAL_CFLAGS)
LOCAL_C_INCLUDES := $(MY_LOCAL_C_INCLUDES)

include $(BUILD_STATIC_LIBRARY)

MY_LOCAL_STATIC_LIBRARIES += Graphics

MY_LOCAL_C_INCLUDES += $(MY_LOCAL_PATH)/Graphics

LOCAL_PATH := $(MY_LOCAL_PATH)/Platform

include $(CLEAR_VARS)

LOCAL_MODULE := Platform
LOCAL_SRC_FILES := <Platform src files>
LOCAL_CFLAGS := $(MY_LOCAL_CFLAGS)
LOCAL_C_INCLUDES := $(MY_LOCAL_C_INCLUDES)

include $(BUILD_STATIC_LIBRARY)

MY_LOCAL_STATIC_LIBRARIES += Platform

MY_LOCAL_C_INCLUDES += $(MY_LOCAL_PATH)/Platform

LOCAL_PATH := $(MY_LOCAL_PATH)

include $(CLEAR_VARS)

LOCAL_MODULE    := Final
LOCAL_SRC_FILES := <Final src files>
LOCAL_STATIC_LIBRARIES := $(MY_LOCAL_STATIC_LIBRARIES)
LOCAL_LDLIBS    := -llog
LOCAL_CFLAGS := $(MY_LOCAL_CFLAGS)
LOCAL_C_INCLUDES := $(MY_LOCAL_C_INCLUDES)

include $(BUILD_SHARED_LIBRARY)
</code>```

Last line of ndk-build V=1 -B:

```<code>SharedLibrary  : libFinal.so
/Users/robbie/Library/Frameworks/Android-NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-g++ -Wl,-soname,libFinal.so -shared --sysroot=/Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm <object files>   /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libBase.a /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libFramework.a /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libGraphics.a /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libPlatform.a /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libstdc++.a  /Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib/libc.so /Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib/libstdc++.so /Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib/libm.so   -Wl,--no-undefined -Wl,-z,noexecstack -L/Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib -llog -lGLESv1_CM -lstdc++ -Wl,-rpath-link=/Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib -lsupc++ -o /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libFinal.so
/Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libPlatform.a(ATexture.o): In function `ATexture':
/Users/robbie/Documents/Apps/Revolution/Android/jni/SpinTap/ATexture.cpp:9: undefined reference to `TextureRenderer::TextureRenderer(unsigned int)'
/Users/robbie/Documents/Apps/Revolution/Android/jni/SpinTap/ATexture.cpp:9: undefined reference to `TextureRenderer::TextureRenderer(unsigned int)'
</code>```

Edit2: TextureRenderer is in Graphics, which is included.

Does anyone have an idea why it may not be working and how to fix it?

答:
This looks like an order-of-linking issue to me.

Your command line is:

```<code>arm-linux-androideabi-g++ -Wl,-soname,libFinal.so -shared \
  libBase.a libFramework.a libGraphics.a libPlatform.a -o libFinal.so
</code>```

and the error is

```<code>libPlatform.a(ATexture.o): In function `ATexture':
ATexture.cpp:9: undefined reference to `TextureRenderer'
ATexture.cpp:9: undefined reference to `TextureRenderer'
</code>```

TextureRenderer is in Graphics. But libGraphics is before libPlatform on the command line. g++ will search each library on the command line in the order they are given, loading functions to resolve external references. It will read libGraphics once, load the functions that resolve external references and move on to libPlatform.

Try changing LOCAL_STATIC_LIBRARIES := $(MY_LOCAL_STATIC_LIBRARIES) to LOCAL_STATIC_LIBRARIES := Platform Graphics Framework Base and see how you get on.

Body:
I started off creating libraries as shared libraries, but I considered it would be more efficient to create one shared libraries and the rest static. When it was all shared, it compiled and linked fine, but moving to static, I get on linking "undefined reference".

Edit: I build all the libraries in one Android.mk

Android.mk:

MY_LOCAL_PATH := $(call my-dir)
MY_LOCAL_CFLAGS := -DDEBUG

TARGET_PLATFORM := 'android-4'

LOCAL_PATH := $(MY_LOCAL_PATH)/../../Base

include $(CLEAR_VARS)

LOCAL_MODULE     := Base
LOCAL_SRC_FILES  := <Base src files>
include $(BUILD_STATIC_LIBRARY)

MY_LOCAL_STATIC_LIBRARIES := Base

MY_LOCAL_C_INCLUDES := $(MY_LOCAL_PATH)/../../Base

LOCAL_PATH := $(MY_LOCAL_PATH)/../../Framework

include $(CLEAR_VARS)

LOCAL_MODULE     := Framework
LOCAL_C_INCLUDES := $(MY_LOCAL_C_INCLUDES)
LOCAL_SRC_FILES  := <Framework src files>
LOCAL_CFLAGS := $(MY_LOCAL_CFLAGS)

include $(BUILD_STATIC_LIBRARY)

MY_LOCAL_STATIC_LIBRARIES += Framework

MY_LOCAL_C_INCLUDES += $(MY_LOCAL_PATH)/../../Framework

LOCAL_PATH := $(MY_LOCAL_PATH)/Graphics

include $(CLEAR_VARS)

LOCAL_MODULE    := Graphics
LOCAL_SRC_FILES := <Graphics src files>
LOCAL_EXPORT_LDLIBS := -lGLESv1_CM
LOCAL_CFLAGS := $(MY_LOCAL_CFLAGS)
LOCAL_C_INCLUDES := $(MY_LOCAL_C_INCLUDES)

include $(BUILD_STATIC_LIBRARY)

MY_LOCAL_STATIC_LIBRARIES += Graphics

MY_LOCAL_C_INCLUDES += $(MY_LOCAL_PATH)/Graphics

LOCAL_PATH := $(MY_LOCAL_PATH)/Platform

include $(CLEAR_VARS)

LOCAL_MODULE := Platform
LOCAL_SRC_FILES := <Platform src files>
LOCAL_CFLAGS := $(MY_LOCAL_CFLAGS)
LOCAL_C_INCLUDES := $(MY_LOCAL_C_INCLUDES)

include $(BUILD_STATIC_LIBRARY)

MY_LOCAL_STATIC_LIBRARIES += Platform

MY_LOCAL_C_INCLUDES += $(MY_LOCAL_PATH)/Platform

LOCAL_PATH := $(MY_LOCAL_PATH)

include $(CLEAR_VARS)

LOCAL_MODULE    := Final
LOCAL_SRC_FILES := <Final src files>
LOCAL_STATIC_LIBRARIES := $(MY_LOCAL_STATIC_LIBRARIES)
LOCAL_LDLIBS    := -llog
LOCAL_CFLAGS := $(MY_LOCAL_CFLAGS)
LOCAL_C_INCLUDES := $(MY_LOCAL_C_INCLUDES)

include $(BUILD_SHARED_LIBRARY)

Last line of ndk-build V=1 -B:

SharedLibrary  : libFinal.so
/Users/robbie/Library/Frameworks/Android-NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-g++ -Wl,-soname,libFinal.so -shared --sysroot=/Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm <object files>   /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libBase.a /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libFramework.a /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libGraphics.a /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libPlatform.a /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libstdc++.a  /Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib/libc.so /Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib/libstdc++.so /Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib/libm.so   -Wl,--no-undefined -Wl,-z,noexecstack -L/Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib -llog -lGLESv1_CM -lstdc++ -Wl,-rpath-link=/Users/robbie/Library/Frameworks/Android-NDK/platforms/android-4/arch-arm/usr/lib -lsupc++ -o /Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libFinal.so
/Users/robbie/Documents/Apps/Revolution/Android/obj/local/armeabi/libPlatform.a(ATexture.o): In function `ATexture':
/Users/robbie/Documents/Apps/Revolution/Android/jni/SpinTap/ATexture.cpp:9: undefined reference to `TextureRenderer::TextureRenderer(unsigned int)'
/Users/robbie/Documents/Apps/Revolution/Android/jni/SpinTap/ATexture.cpp:9: undefined reference to `TextureRenderer::TextureRenderer(unsigned int)'

Edit2: TextureRenderer is in Graphics, which is included.

Does anyone have an idea why it may not be working and how to fix it?

Body:
This looks like an order-of-linking issue to me.

Your command line is:

arm-linux-androideabi-g++ -Wl,-soname,libFinal.so -shared \
  libBase.a libFramework.a libGraphics.a libPlatform.a -o libFinal.so

and the error is

libPlatform.a(ATexture.o): In function `ATexture':
ATexture.cpp:9: undefined reference to `TextureRenderer'
ATexture.cpp:9: undefined reference to `TextureRenderer'

TextureRenderer is in Graphics. But libGraphics is before libPlatform on the command line. g++ will search each library on the command line in the order they are given, loading functions to resolve external references. It will read libGraphics once, load the functions that resolve external references and move on to libPlatform.

Try changing LOCAL_STATIC_LIBRARIES := $(MY_LOCAL_STATIC_LIBRARIES) to LOCAL_STATIC_LIBRARIES := Platform Graphics Framework Base and see how you get on.


问:
"insufficient memory for Java Runtime Environment to continue" in Ubuntu terminal
I am trying to run java -Xmx5g -cp stanford-corenlp-3.8.0.jar:stanford-corenlp-models-3.8.0.jar:* edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner,parse,mention,coref -coref.algorithm neural -file example_file.txt to find mentions of the same entity in a text.
But when I run that command in terminal, the process was killed and the error is written in a log, saying that insufficient memory for Java Runtime Environment to continue.

I am using Ubuntu with:

java version "1.8.0_151".

Java(TM) SE Runtime Environment (build 1.8.0_151-b12)

Java Hotspot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

As the log is quite long and the question body cannot fit all the log's details.

Here is the log: error log

[Update] I have increase the physical memory of my virtual machine. Now I'm getting this error:

```<code>Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:3332)
    at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
    at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:649)
    at java.lang.StringBuilder.append(StringBuilder.java:202)
    at edu.stanford.nlp.ling.SentenceUtils.listToString(SentenceUtils.java:186)
    at edu.stanford.nlp.ling.SentenceUtils.listToString(SentenceUtils.java:169)
    at edu.stanford.nlp.ling.SentenceUtils.listToString(SentenceUtils.java:148)
    at edu.stanford.nlp.pipeline.ParserAnnotator.doOneSentence(ParserAnnotator.java:360)
    at edu.stanford.nlp.pipeline.ParserAnnotator.doOneSentence(ParserAnnotator.java:254)
    at edu.stanford.nlp.pipeline.SentenceAnnotator.annotate(SentenceAnnotator.java:102)
    at edu.stanford.nlp.pipeline.AnnotationPipeline.annotate(AnnotationPipeline.java:76)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.annotate(StanfordCoreNLP.java:599)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.annotate(StanfordCoreNLP.java:609)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP$$Lambda$55/45416784.accept(Unknown Source)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.processFiles(StanfordCoreNLP.java:1172)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.processFiles(StanfordCoreNLP.java:945)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.run(StanfordCoreNLP.java:1274)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.main(StanfordCoreNLP.java:1345)
</code>```

Is there a way to solve this problem?

答:
The error report says this:

```<code># There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 335785984 bytes
  for committing reserved memory.
# Possible reasons:
#   The system is out of physical RAM or swap space
#   In 32 bit mode, the process size limit was hit
</code>```

Taking this at face value:

The first explanation means that the operating system has refused a request from the JVM to allocate a large chunk of native memory because the resources (physical memory or swap space) are not available.

You are using a 64bit JVM so the second possible explanation is not applicable.

The first explanation is plausible.  Possible fixes might be:

add more physical memory; e.g. get a bigger machine or virtual machine

add more swap space

reduce max heapsize specified via the -Xmx parameter

Body:
I am trying to run java -Xmx5g -cp stanford-corenlp-3.8.0.jar:stanford-corenlp-models-3.8.0.jar:* edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner,parse,mention,coref -coref.algorithm neural -file example_file.txt to find mentions of the same entity in a text.
But when I run that command in terminal, the process was killed and the error is written in a log, saying that insufficient memory for Java Runtime Environment to continue.

I am using Ubuntu with:

java version "1.8.0_151".

Java(TM) SE Runtime Environment (build 1.8.0_151-b12)

Java Hotspot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

As the log is quite long and the question body cannot fit all the log's details.

Here is the log: error log

[Update] I have increase the physical memory of my virtual machine. Now I'm getting this error:

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:3332)
    at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
    at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:649)
    at java.lang.StringBuilder.append(StringBuilder.java:202)
    at edu.stanford.nlp.ling.SentenceUtils.listToString(SentenceUtils.java:186)
    at edu.stanford.nlp.ling.SentenceUtils.listToString(SentenceUtils.java:169)
    at edu.stanford.nlp.ling.SentenceUtils.listToString(SentenceUtils.java:148)
    at edu.stanford.nlp.pipeline.ParserAnnotator.doOneSentence(ParserAnnotator.java:360)
    at edu.stanford.nlp.pipeline.ParserAnnotator.doOneSentence(ParserAnnotator.java:254)
    at edu.stanford.nlp.pipeline.SentenceAnnotator.annotate(SentenceAnnotator.java:102)
    at edu.stanford.nlp.pipeline.AnnotationPipeline.annotate(AnnotationPipeline.java:76)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.annotate(StanfordCoreNLP.java:599)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.annotate(StanfordCoreNLP.java:609)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP$$Lambda$55/45416784.accept(Unknown Source)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.processFiles(StanfordCoreNLP.java:1172)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.processFiles(StanfordCoreNLP.java:945)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.run(StanfordCoreNLP.java:1274)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.main(StanfordCoreNLP.java:1345)

Is there a way to solve this problem?

Body:
The error report says this:

# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 335785984 bytes
  for committing reserved memory.
# Possible reasons:
#   The system is out of physical RAM or swap space
#   In 32 bit mode, the process size limit was hit

Taking this at face value:

The first explanation means that the operating system has refused a request from the JVM to allocate a large chunk of native memory because the resources (physical memory or swap space) are not available.

You are using a 64bit JVM so the second possible explanation is not applicable.

The first explanation is plausible.  Possible fixes might be:

add more physical memory; e.g. get a bigger machine or virtual machine

add more swap space

reduce max heapsize specified via the -Xmx parameter