问:
class attributes are not changing after reaching specific width in jquery
```<code>$(window).on('resize', function (event) {
if ($('body').width() <= 480) {

            $("circle").attr("cx", 115).attr("cy", 80).attr("r", 70).attr("transform", "rotate(-84, 100, 99)");
            $("#skills .row [class*=col-]").toggleClass("col-xs-6 col-xs-12");

        }
}
</code>```

<p>My code is it should remove the attributes and assign the give value once it reaches width < 480. But this is not happening when i inspect the element and set the screen size as iphone 5s( width:320px). May i know the reason why its not changing? I even changed the body.width() to window.width() but its not working. </p>

答:
you can use jquery resize function

$('body').resize(function(){
    console.log('body dimension changed');
    if ($('body').width() <= 480) {
        $("circle").attr("cx", 115).attr("cy", 80).attr("r", 70).attr("transform", "rotate(-84, 100, 99)");
        $("#skills .row [class*=col-]").toggleClass("col-xs-6 col-xs-12");
    }
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script></code>```

Body:
$(window).on('resize', function (event) {
if ($('body').width() <= 480) {

            $("circle").attr("cx", 115).attr("cy", 80).attr("r", 70).attr("transform", "rotate(-84, 100, 99)");
            $("#skills .row [class*=col-]").toggleClass("col-xs-6 col-xs-12");

        }
}

My code is it should remove the attributes and assign the give value once it reaches width < 480. But this is not happening when i inspect the element and set the screen size as iphone 5s( width:320px). May i know the reason why its not changing? I even changed the body.width() to window.width() but its not working.

Body:
you can use jquery resize function

$('body').resize(function(){
    console.log('body dimension changed');
    if ($('body').width() <= 480) {
        $("circle").attr("cx", 115).attr("cy", 80).attr("r", 70).attr("transform", "rotate(-84, 100, 99)");
        $("#skills .row [class*=col-]").toggleClass("col-xs-6 col-xs-12");
    }
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>


来源: stackexchange

问:
How to Start Save-As Dialog with a FileStream
My project is a Sharepoint Web-App, and it will generate a text file for the user and offer it for the user to download.

The web-app generates a string value and should use FileStream to create a text file out of it.  The user clicks a button and they should get a save-as dialogue.

Now, it is simple enough to use FileStream to write to the user's local drive, but how do you prompt them for the location and THEN save it there?

There are lots of questions about how to write to the local disk, and there are questions about how to open the save-dialogue in the browser.  But I have not found any that answer the question of using the two methods together.

To write the file, we can use this:

```<code>        using (var fs = new FileStream(@"C:\test.txt", FileMode.Create, FileAccess.ReadWrite)) {
            TextWriter tw = new StreamWriter(fs);
            tw.Write("Hello World");
            tw.Flush();
        }
</code>```

and to open the save-as dialog, we can do this, which will tell the browser a file is ready for downloading which will open the browser's own save dialogue:

```<code>            if (resp.IsClientConnected) {
                resp.Clear();
                resp.ClearHeaders();
                //Indicate the type of data being sent
                resp.ContentType = "text/plain";    //".htm", "html" = "text/html"
                resp.AppendHeader("Content-Disposition", "attachment; filename=\"" + Path.GetFileName(gentextfilename) + "\"");
                resp.AppendHeader("Content-Length", reader.BaseStream.Length.ToString());
                resp.TransmitFile(file_name); //does not buffer into memory, therefore scales better for large files and heavy usage
                resp.End();
            }
</code>```

Now, is there a way to combine these?  I don't want to save the file to the server and then download it.  I want to save it directly to a save location specified by the user.  And to make all of this worse, it's a Sharepoint web-app, so it will run inside of Sharepoint, so I don't think you can use the folderBrowserDialog1 or SaveFileDialog method like you can in a desktop application.

Summary of What Answer is Being Sought:

How can I create a file (without creating one on the server) to save to download location of the user's choice?

答:
No, there is no way to do that directly as you are used to in Windows desktop development. This is the nature of the protocol used.

You can't use the desktop file dialogs from within your ASP.NET application to ask the user where to save things. You have to rely on the browser to do so.

The best option you have is what you already show: content disposition. Give the browser as much information as you can and let the user decide what to do with it.

If you can use ASP.NET MVC, you can take advantage of the streamed responses, like FileStreamResult or using standard ASP.NET, using CopyTo.

ContentLicense: CC BY-SA 3.0

Body:
My project is a Sharepoint Web-App, and it will generate a text file for the user and offer it for the user to download.

The web-app generates a string value and should use FileStream to create a text file out of it.  The user clicks a button and they should get a save-as dialogue.

Now, it is simple enough to use FileStream to write to the user's local drive, but how do you prompt them for the location and THEN save it there?

There are lots of questions about how to write to the local disk, and there are questions about how to open the save-dialogue in the browser.  But I have not found any that answer the question of using the two methods together.

To write the file, we can use this:

        using (var fs = new FileStream(@"C:\test.txt", FileMode.Create, FileAccess.ReadWrite)) {
            TextWriter tw = new StreamWriter(fs);
            tw.Write("Hello World");
            tw.Flush();
        }

and to open the save-as dialog, we can do this, which will tell the browser a file is ready for downloading which will open the browser's own save dialogue:

            if (resp.IsClientConnected) {
                resp.Clear();
                resp.ClearHeaders();
                //Indicate the type of data being sent
                resp.ContentType = "text/plain";    //".htm", "html" = "text/html"
                resp.AppendHeader("Content-Disposition", "attachment; filename=\"" + Path.GetFileName(gentextfilename) + "\"");
                resp.AppendHeader("Content-Length", reader.BaseStream.Length.ToString());
                resp.TransmitFile(file_name); //does not buffer into memory, therefore scales better for large files and heavy usage
                resp.End();
            }

Now, is there a way to combine these?  I don't want to save the file to the server and then download it.  I want to save it directly to a save location specified by the user.  And to make all of this worse, it's a Sharepoint web-app, so it will run inside of Sharepoint, so I don't think you can use the folderBrowserDialog1 or SaveFileDialog method like you can in a desktop application.

Summary of What Answer is Being Sought:

How can I create a file (without creating one on the server) to save to download location of the user's choice?


问:
Excel If value in Cell is 181 then I want to display value in F28
I've tried the following but it doesn't seem to work

```<code>=IF(D28="181", "",F28)
</code>```

I'm making a filter to display a value in a column of cells the the associated row value is 181, basically I have a bunch of data and column D identifies the type of data. So I want to know if D(#)=181 if it does display the column value from F#

but it doesn't seem to mater what value I have in D it always outputs something in the cell when it should be empty.

答:
Your value if true and value if false statements are switched. Try
 =IF(D28 = 181, F28, "")

Body:
I've tried the following but it doesn't seem to work

=IF(D28="181", "",F28)

I'm making a filter to display a value in a column of cells the the associated row value is 181, basically I have a bunch of data and column D identifies the type of data. So I want to know if D(#)=181 if it does display the column value from F#

but it doesn't seem to mater what value I have in D it always outputs something in the cell when it should be empty.


问:
How to copy specific cell content from word document and create new word document
i am working on a project for which i have word document having content in tabular format. for that i need to copy specific cell content from that word file and create new word file with that selected cells. Will it Possible (Or suggest any other method to achieve this).

If Possible, please help me on that.
Thank You in Advance.

答: If you first need to read the contents of your file you can achieve this by reading Word DOM (see documentation of that library here). Once you've read the data, you can either (1) create a document from scratch using DOM commands, or insert the new content into a template document to get the final result.</p>


问:
Get the full email body content using gmail api and android client
I need to get the full email body content using android client and gmail api. Following is the android code i have used to get email content

```<code>     String user = "me";
        List<String> messages=new ArrayList<>();
        ListMessagesResponse listresponse=mService.users().messages().list(user).execute();

        int a=0;
        for(Message message:listresponse.getMessages()){
            messages.add(message.getId());
            a++;
        }

        for(int i=0;i<=a;i++){
            Message message=mService.users().messages().get(user, messages.get(i)).setFormat("raw").execute();

            try {

                Log.d("Body", String.valueOf(message));

            }
            catch (Throwable t){
                Log.e("My app", "not done");
            }
        }

        return messages;

    }
</code>```

Then i'm receiving the following output.

```<code>     D/Body: {"historyId":"******","id":"************","internalDate":"************","labelIds":["CATEGORY_PROMOTIONS","UNREAD","INBOX"],"raw":"RGVsaXZlcmVkLVRvOiBqYW5pdGhhMjAwQGdtYWlsLmNvbQ0KUmVjZWl2ZWQ6IGJ5IDEwLjE5NC4yMjguNzEgd2l0aCBTTVRQIGlkIHNnN2NzcDE4MTkwMzd3amM7DQogICAgICAgIE1vbiwgNiBGZWIgMjAxNyAxMDoyMzozMCAtMDgwMCAoUFNUKQ0KWC1SZWNlaXZlZDogYnkgMTAuODQuMjMyLjIwMSB3aXRoIFNNVFAgaWQgeDltcjE5MzY2MDAycGxtLjEwMi4xNDg2NDA1NDA5OTkyOw0KICAgICAgICBNb24sIDA2IEZlYiAyMDE3IDEwOjIzOjI5IC0wODAwIChQU1QpDQpSZXR1cm4tUGF0aDogPHVkZW15QGVtYWlsLnVkZW15LmNvbT4NClJlY2VpdmVkOiBmcm9tIG9tcC5lbWFpbC51ZGVteS5jb20gKG9tcC5lbWFpbC51ZGVteS5jb20uIFsxOTkuNy4yMDIuMjQ0XSkNCiAgICAgICAgYnkgbXguZ29vZ2xlLmNvbSB3aXRoIEVTTVRQUyBpZCBwODNzaTE0MzA5NzNwZmouMzUuMj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25lU3RlcENvbmZpcm1BY3Rpb24_WUVTPXRydWUmX3JpXz1YMEd6YzJYJTNEWVFwZ2xMakhKbFlRR283STRpcHpmNzIyemV6YmUzMHpncllqY1hjOWFzdXc2YW96Y
</code>```

I'm having trouble with decoding the body content in this output. So what would be the mechanism that i have to follow to get the full body content? Thank you.

答:
This worked

String user = "me";
List<String> messageList = new ArrayList<>();
String query = "in:inbox";
ListMessagesResponse messageResponse =
        mService.users().messages().list(user).setQ(query).setMaxResults(Long.valueOf(6)).execute();

List<Message> messages = messageResponse.getMessages();

for (Message message : messages) {
    Message message2 = mService.users().messages().get(user, message.getId()).execute();

    //Get Body
    byte[] bodyBytes = Base64.decodeBase64(message2.getPayload().getParts().get(0).getBody().getData().trim().toString()); // get body
    String body = new String(bodyBytes, "UTF-8");

    messageList.add(body);
    Log.d("bb", body);
}
```

Body:
I need to get the full email body content using android client and gmail api. Following is the android code i have used to get email content

     String user = "me";
        List<String> messages=new ArrayList<>();
        ListMessagesResponse listresponse=mService.users().messages().list(user).execute();

        int a=0;
        for(Message message:listresponse.getMessages()){
            messages.add(message.getId());
            a++;
        }

        for(int i=0;i<=a;i++){
            Message message=mService.users().messages().get(user, messages.get(i)).setFormat("raw").execute();

            try {

                Log.d("Body", String.valueOf(message));

            }
            catch (Throwable t){
                Log.e("My app", "not done");
            }
        }

        return messages;

    }

Then i'm receiving the following output.

     D/Body: {"historyId":"******","id":"************","internalDate":"************","labelIds":["CATEGORY_PROMOTIONS","UNREAD","INBOX"],"raw":"RGVsaXZlcmVkLVRvOiBqYW5pdGhhMjAwQGdtYWlsLmNvbQ0KUmVjZWl2ZWQ6IGJ5IDEwLjE5NC4yMjguNzEgd2l0aCBTTVRQIGlkIHNnN2NzcDE4MTkwMzd3amM7DQogICAgICAgIE1vbiwgNiBGZWIgMjAxNyAxMDoyMzozMCAtMDgwMCAoUFNUKQ0KWC1SZWNlaXZlZDogYnkgMTAuODQuMjMyLjIwMSB3aXRoIFNNVFAgaWQgeDltcj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dGhhMjAwQGdtYWlsLmNvbQ0KRnJvbTogIlVkZW15IiA8dWRlbXlAZW1haWwudWRlbXkuY29tPg0KUmVwbHktVG86ICJVZGVteSIgPHJlcGx5QGVtYWlsLnVkZW15LmNvbT4NClN1YmplY3Q6IFRhcmdldCB5b3VyIGdvYWxzIHdpdGggdG9wIGNvdXJzZXMNCkZlZWRiYWNrLUlEOiA1MTk5NToxMjE0NDM1Om9yYWNsZXJzeXMNCkxpc3QtVW5zdWJzY3JpYmU6IDxodHRwczovL2VtYWlsLnVkZW15LmNvbS9wdWIvb3B0b3V0L1Vuc3Vic2NyaWJlT25lU3RlcENvbmZpcm1BY3Rpb24_WUVTPXRydWUmX3JpXz1YMEd6YzJYJTNEWVFwZ2xMakhKbFlRR283STRpcHpmNzIyemV6YmUzMHpncllqY1hjOWFzdXc2YW96Y

I'm having trouble with decoding the body content in this output. So what would be the mechanism that i have to follow to get the full body content? Thank you.

ContentLicense: CC BY-SA 4.0


问:
How to implement exponentiation of a rational number without nth root?
Its available for me only log(base "e"), sin, tan and sqrt (only square root) functions and the basic arithmetical operators (+ - * / mod). I have also the "e" constant.

I'm experimenting several problems with Deluge (zoho.com) for these restrictions. I must implement exponentiation of rational (fraction) bases and exponents.

答:
If you have a function F() that does e^x, where e is the constant, and x is any number, then you can do this: (a is base, b is exponent, ln is log-e)

a^b = F(b * ln(a))

If you don't have F() that does e^x, then it gets trickier. If your exponent (b) is rational, then you should be able to find integers m and n so that b = m/n, using a loop of some sort. Once you have m and n, you make another loop which multiples a by itself m times to get a^m, then multiples a by itself n times to get a^n, then divide a^m/a^n to get a^(m/n), which is a^b.

ContentLicense: CC BY-SA 2.5


问:
Spring Boot project using a spring data jpa project to retrieve users
I have a Spring Data JPA project to access my Database and retrieve users credentials. I packaged this project as a jar (not an executable jar) and included it as a maven dependency to another Spring boot project because I wanted to reuse the same entities and repositories previously developed. every time I run my Spring Boot Application I get this error:

```<code>Action: If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).
</code>```

I am starting to wonder if what I am doing is even possible?
PS: I don't want to mix the JPA project with the controllers and services project

答:
Some time ago I got the same error, I fix it adding this:

```<code>@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
</code>```

to the boot class, for example:

```<code>package com.adapter;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

@SpringBootApplication
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
public class DBAdapterApplication {
    public static void main(String[] args) {
        SpringApplication.run(DBAdapterApplication.class, args);
    }
}
</code>```

Body:
I have a Spring Data JPA project to access my Database and retrieve users credentials. I packaged this project as a jar (not an executable jar) and included it as a maven dependency to another Spring boot project because I wanted to reuse the same entities and repositories previously developed. every time I run my Spring Boot Application I get this error:

Action: If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).

I am starting to wonder if what I am doing is even possible?
PS: I don't want to mix the JPA project with the controllers and services project

Body:
Some time ago I got the same error, I fix it adding this:

@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})

to the boot class, for example:

package com.adapter;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

@SpringBootApplication
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
public class DBAdapterApplication {
    public static void main(String[] args) {
        SpringApplication.run(DBAdapterApplication.class, args);
    }
}


问:
PySpark - UnpicklingError: NEWOBJ class argument has NULL tp_new
When I am executing the bellow, I am getting Unpickling Error

```<code>rdd = sc.parallelize([('HOMICIDE', {'2017': 1}),
('DECEPTIVE PRACTICE', {'2015': 2, '2017': 2, '2016': 8}),
('ROBBERY', {'2016': 2})])

rdd.flatMapValues(dict.items).collect()
</code>```

The error is as bellow, Is there any issue on using flatMapValues on dictionay values

```<code>  File "/usr/hdp/2.3.4.0-3485/spark/python/lib/pyspark.zip/pyspark/worker.py", line 98, in main
    command = pickleSer._read_with_length(infile)
  File "/usr/hdp/2.3.4.0-3485/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 164, in _read_with_length
    return self.loads(obj)
  File "/usr/hdp/2.3.4.0-3485/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 422, in loads
    return pickle.loads(obj)
UnpicklingError: NEWOBJ class argument has NULL tp_new
) [duplicate 3]
17/06/06 17:01:14 INFO TaskSchedulerImpl: Removed TaskSet 0.0, whose tasks have all completed, from pool
</code>```

答:
```<code>rdd = sc.parallelize([('HOMICIDE', {'2017': 1}),
                      ('DECEPTIVE PRACTICE', {'2015': 2, '2017': 2, '2016': 8}),
                      ('ROBBERY', {'2016': 2})])

rdd.flatMapValues(lambda data: data.items()).collect()

[('HOMICIDE', ('2017', 1)),
 ('DECEPTIVE PRACTICE', ('2015', 2)),
 ('DECEPTIVE PRACTICE', ('2017', 2)),
 ('DECEPTIVE PRACTICE', ('2016', 8)),
 ('ROBBERY', ('2016', 2))]
</code>```

dict.items is method descriptor. You have to supply a function to inform flatmap how to unpack those values. I did that by passing in labmda function to the flatMap function.

Body:
When I am executing the bellow, I am getting Unpickling Error

rdd = sc.parallelize([('HOMICIDE', {'2017': 1}),
('DECEPTIVE PRACTICE', {'2015': 2, '2017': 2, '2016': 8}),
('ROBBERY', {'2016': 2})])

rdd.flatMapValues(dict.items).collect()

The error is as bellow, Is there any issue on using flatMapValues on dictionay values

  File "/usr/hdp/2.3.4.0-3485/spark/python/lib/pyspark.zip/pyspark/worker.py", line 98, in main
    command = pickleSer._read_with_length(infile)
  File "/usr/hdp/2.3.4.0-3485/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 164, in _read_with_length
    return self.loads(obj)
  File "/usr/hdp/2.3.4.0-3485/spark/python/lib/pyspark.zip/pyspark/serializers.py", line 422, in loads
    return pickle.loads(obj)
UnpicklingError: NEWOBJ class argument has NULL tp_new
) [duplicate 3]
17/06/06 17:01:14 INFO TaskSchedulerImpl: Removed TaskSet 0.0, whose tasks have all completed, from pool

Body:
rdd = sc.parallelize([('HOMICIDE', {'2017': 1}),
                      ('DECEPTIVE PRACTICE', {'2015': 2, '2017': 2, '2016': 8}),
                      ('ROBBERY', {'2016': 2})])

rdd.flatMapValues(lambda data: data.items()).collect()

[('HOMICIDE', ('2017', 1)),
 ('DECEPTIVE PRACTICE', ('2015', 2)),
 ('DECEPTIVE PRACTICE', ('2017', 2)),
 ('DECEPTIVE PRACTICE', ('2016', 8)),
 ('ROBBERY', ('2016', 2))]

dict.items is method descriptor. You have to supply a function to inform flatmap how to unpack those values. I did that by passing in labmda function to the flatMap function.


问:
Ultragrid RTSP error
i have a problem with the RTSP server from the ultragrid.

i download Ultragrid-master, the git source code, i run autogen.sh
next i run ./configure --enable-rtsp-server, now i have the rtsp server enabled with all dependencies ,liblivemedia-dev. But when i make the file i have this error.

Configure Step

```<code>./configure --enable-portaudio --enable-rtsp-server
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... none
checking for gcc option to accept ISO C99... -std=gnu99
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... none
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for an ANSI C-conforming const... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for size_t... yes
checking whether byte ordering is bigendian... no
checking whether char is unsigned... no
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking stropts.h usability... yes
checking stropts.h presence... yes
checking for stropts.h... yes
checking sys/filio.h usability... no
checking sys/filio.h presence... no
checking for sys/filio.h... no
checking sys/wait.h usability... yes
checking sys/wait.h presence... yes
checking for sys/wait.h... yes
checking size of int *... 8
checking whether byte ordering is bigendian... (cached) no
checking size of size_t... 8
checking GIT presence... checking OS family... Linux
checking OS kernel version (major)... 3
checking OS kernel version (minor)... 19
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking for if_nametoindex... yes
checking for strtok_r... yes
checking for drand48... yes
checking for int8_t... yes
checking for int16_t... yes
checking for int32_t... yes
checking for int64_t... yes
checking for uint8_t in <stdint.h>... yes
checking for uint16_t in <stdint.h>... yes
checking for uint32_t in <stdint.h>... yes
checking for library containing socket... none required
checking for library containing inet_addr... none required
checking for timer_create in -lrt... yes
checking for sin... no
checking for main in -lieee... yes
checking for sched_setscheduler... yes
checking for pthread_create in -lpthread... yes
checking for X... libraries , headers
checking for gethostbyname... yes
checking for connect... yes
checking for remove... yes
checking for shmat... yes
checking for IceConnectionNumber in -lICE... no
checking whether X11 headers are broken... no
checking dvs_clib.h usability... no
checking dvs_clib.h presence... no
checking for dvs_clib.h... no
checking for sv_open in -ldvsoem... no
checking for ./DeckLink/Linux/DeckLinkAPI.h... no
checking for ./DeckLink/Linux/DeckLinkAPIDispatch.cpp... no
checking for main in -lDeckLinkAPI... no
checking how to run the C++ preprocessor... g++ -E
checking BlueVelvet.h usability... no
checking BlueVelvet.h presence... no
checking for BlueVelvet.h... no
checking for BlueVelvetFactory in -lBlueVelvet64... no
checking for hanc_decoder_ex in -lBlueANCUtils64... no
checking for VideoMasterHD_Core.h... no
checking for VideoMasterHD_Sdi.h... no
checking for VideoMasterHD_Sdi_Audio.h... no
checking SDL/SDL.h usability... no
checking SDL/SDL.h presence... no
checking for SDL/SDL.h... no
SDL.h not found.
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for RTSP... no
checking for /usr/include/liveMedia/liveMedia.hh... yes
checking for RESIZE... no
checking for BLANK... no
checking GL/glew.h usability... no
checking GL/glew.h presence... no
checking for GL/glew.h... no
checking for GL/gl.h... no
checking for GL/glx.h... no
configure: WARNING: OpenGL headers (gl.h, glx.h) not found or not usable.
checking for GL/glx.h... (cached) no
checking for GL/gl.h... (cached) no
checking for glBindTexture in -lGL... no
checking for glXCreateNewContext in -lGL... no
checking for XCreateWindow in -lX11... yes
checking X11/Xlib.h usability... yes
checking X11/Xlib.h presence... yes
checking for X11/Xlib.h... yes
checking X11/Xutil.h usability... yes
checking X11/Xutil.h presence... yes
checking for X11/Xutil.h... yes
checking for XGetImage in -lX11... yes
checking for XFixesGetCursorImage in -lXfixes... no
checking X11/extensions/Xfixes.h usability... no
checking X11/extensions/Xfixes.h presence... no
checking for X11/extensions/Xfixes.h... no
checking for nvcc... no
checking for LIBGPUJPEG... no
checking for main in -lsail... no
checking for main in -lsail... (cached) no
checking for /usr/local/sage/include/sail.h... no
checking portaudio.h usability... yes
checking portaudio.h presence... yes
checking for portaudio.h... yes
checking for Pa_GetDeviceCount in -lportaudio... yes
checking jack/jack.h usability... yes
checking jack/jack.h presence... yes
checking for jack/jack.h... yes
checking for jack_client_new in -ljack... yes
checking alsa/asoundlib.h usability... yes
checking alsa/asoundlib.h presence... yes
checking for alsa/asoundlib.h... yes
checking for snd_pcm_open in -lasound... yes
checking for TEXT... no
checking for V4L2... no
checking for LIBAVCODEC... no
checking for LIBAVUTIL... no
checking for CURSES... no
checking for CURSES... no
checking for CRYPTO... yes
checking for AES_ctr128_encrypt... yes
checking for VIDEO_MIX... no
checking for LAVC_HWDEC... no

UltraGrid configuration summary:

  Target ...................... x86_64-unknown-linux-gnu
  Debug output ................ no
  Profiling support ........... no
  IPv6 support ................ yes
  RT priority ................. no
  Standalone modules .......... no
  License ..................... GPLv2
  iHDTV support ............... no
  OpenSSL-libcrypto ........... yes
  CUDA support ................ no (host code compiler: default)
  Library live555 ............. yes
  Syphon ...................... no

  AJA ......................... no
  AV Foundation ............... no
  Bluefish444 ................. no (audio: no)
  DeckLink .................... no
  DirectShow .................. no
  DELTACAST ................... no
  DVS ......................... no
  OpenGL ...................... no
  Quicktime ................... no
  SAGE ........................ no
  SDL ......................... no
  Screen Capture .............. yes
  V4L2 ........................ no
  RTSP Capturer Client ........ no
  SW Video Mix ................ no

  Portaudio ................... yes
  ALSA ........................ yes
  CoreAudio ................... no
  JACK  ....................... yes
  JACK transport .............. no

  Realtime DXT (OpenGL) ....... no
  JPEG ........................ no
  JPEG to DXT ................. no
  CUDA DXT .................... no
  UYVY dummy compression ...... no
  Libavcodec .................. no

  blank capture filter ........ no
  resize capture filter ....... no
  text postprocess and filter . no
  RTSP Server ................. yes
  scale postprocessor ......... no
  testcard extras ............. no
  GPU accelerated LDGM ........ no
  MCU-like video mixer ........ no
  Libavcodec hw decoding ...... no

checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/config.h
config.status: executing depfiles commands
</code>```

Make Step Error

```<code>make
mkdir -p src src/audio src/audio/capture src/audio/codec src/audio/playback src/capture_filter src/compat src/crypto src/hd-rum-translator src/ihdtv src/rtp src/rtsp src/utils src/video_capture src/video_compress src/video_decompress src/video_display src/video_rxtx src/vo_postprocess ag_plugin bin cuda_dxt dxt_compress ldgm/src ldgm/matrix-gen lib lib/ultragrid
touch src/dir-stamp
gcc -std=gnu99 -g -O2 -I. -fPIC -msse4 -pipe -W -Wall -Wcast-qual -Wcast-align -Wbad-function-cast -Wmissing-prototypes -Wmissing-declarations -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment    -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/audio/capture/alsa.c -o src/audio/capture/alsa.o
gcc -std=gnu99 -g -O2 -I. -fPIC -msse4 -pipe -W -Wall -Wcast-qual -Wcast-align -Wbad-function-cast -Wmissing-prototypes -Wmissing-declarations -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment    -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/audio/capture/jack.c -o src/audio/capture/jack.o
gcc -std=gnu99 -g -O2 -I. -fPIC -msse4 -pipe -W -Wall -Wcast-qual -Wcast-align -Wbad-function-cast -Wmissing-prototypes -Wmissing-declarations -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment    -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/audio/capture/portaudio.c -o src/audio/capture/portaudio.o
gcc -std=gnu99 -g -O2 -I. -fPIC -msse4 -pipe -W -Wall -Wcast-qual -Wcast-align -Wbad-function-cast -Wmissing-prototypes -Wmissing-declarations -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment    -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/audio/playback/alsa.c -o src/audio/playback/alsa.o
gcc -std=gnu99 -g -O2 -I. -fPIC -msse4 -pipe -W -Wall -Wcast-qual -Wcast-align -Wbad-function-cast -Wmissing-prototypes -Wmissing-declarations -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment    -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/audio/playback/jack.c -o src/audio/playback/jack.o
g++ -g -O2 -I. -std=gnu++11 -fPIC -msse4 -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment   -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/audio/playback/portaudio.cpp -o src/audio/playback/portaudio.o
g++ -g -O2 -I. -std=gnu++11 -fPIC -msse4 -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment   -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/crypto/openssl_decrypt.cpp -o src/crypto/openssl_decrypt.o
g++ -g -O2 -I. -std=gnu++11 -fPIC -msse4 -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment   -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/crypto/openssl_encrypt.cpp -o src/crypto/openssl_encrypt.o
g++ -g -O2 -I. -std=gnu++11 -fPIC -msse4 -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment   -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/rtsp/BasicRTSPOnlyServer.cpp -o src/rtsp/BasicRTSPOnlyServer.o
g++ -g -O2 -I. -std=gnu++11 -fPIC -msse4 -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment   -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/rtsp/BasicRTSPOnlySubsession.cpp -o src/rtsp/BasicRTSPOnlySubsession.o
src/rtsp/BasicRTSPOnlySubsession.cpp: In member function ‘virtual void BasicRTSPOnlySubsession::startStream(unsigned int, void*, void (*)(void*), void*, short unsigned int&, unsigned int&, void (*)(void*, u_int8_t), void*)’:
src/rtsp/BasicRTSPOnlySubsession.cpp:243:11: error: ‘struct msg_sender’ has no member named ‘port’
    msgV1->port = ntohs(Vdestination->rtpPort.num());
           ^
src/rtsp/BasicRTSPOnlySubsession.cpp:272:11: error: ‘struct msg_sender’ has no member named ‘port’
    msgA1->port = ntohs(Adestination->rtpPort.num());
           ^
src/rtsp/BasicRTSPOnlySubsession.cpp: In member function ‘virtual void BasicRTSPOnlySubsession::deleteStream(unsigned int, void*&)’:
src/rtsp/BasicRTSPOnlySubsession.cpp:304:11: error: ‘struct msg_sender’ has no member named ‘port’
    msgV1->port = rtp_port;
           ^
src/rtsp/BasicRTSPOnlySubsession.cpp:334:11: error: ‘struct msg_sender’ has no member named ‘port’
    msgA1->port = rtp_port_audio;
           ^
make: *** [src/rtsp/BasicRTSPOnlySubsession.o] Error 1
</code>```

I test in linux ubuntu.

Can anybody help me?

答:
This is because the live555 release you are using in not compatible with ultragrid.

This code that doesnot build changed in this commit ea1971c116dddee7a7cffe014c9a6d98f8d969fd, that indicate the live555 release to use.

In order to build with the recommanded release of live you can proceed like this :

```<code>git clone https://github.com/xanview/live555
pushd live555
git checkout 35c375c
./genMakefile linux
make PREFIX=/tmp/live install
popd
./configure --enable-rtsp-server --with-live555=/tmp/live
make
</code>```

Title: Ultragrid RTSP error

Body:
i have a problem with the RTSP server from the ultragrid.

i download Ultragrid-master, the git source code, i run autogen.sh
next i run ./configure --enable-rtsp-server, now i have the rtsp server enabled with all dependencies ,liblivemedia-dev. But when i make the file i have this error.

Configure Step

./configure --enable-portaudio --enable-rtsp-server
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... none
checking for gcc option to accept ISO C99... -std=gnu99
checking how to run the C preprocessor... gcc -std=gnu99 -E
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking dependency style of g++... none
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for an ANSI C-conforming const... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for size_t... yes
checking whether byte ordering is bigendian... no
checking whether char is unsigned... no
checking for stdbool.h that conforms to C99... yes
checking for _Bool... yes
checking stropts.h usability... yes
checking stropts.h presence... yes
checking for stropts.h... yes
checking sys/filio.h usability... no
checking sys/filio.h presence... no
checking for sys/filio.h... no
checking sys/wait.h usability... yes
checking sys/wait.h presence... yes
checking for sys/wait.h... yes
checking size of int *... 8
checking whether byte ordering is bigendian... (cached) no
checking size of size_t... 8
checking GIT presence... checking OS family... Linux
checking OS kernel version (major)... 3
checking OS kernel version (minor)... 19
checking termios.h usability... yes
checking termios.h presence... yes
checking for termios.h... yes
checking for if_nametoindex... yes
checking for strtok_r... yes
checking for drand48... yes
checking for int8_t... yes
checking for int16_t... yes
checking for int32_t... yes
checking for int64_t... yes
checking for uint8_t in <stdint.h>... yes
checking for uint16_t in <stdint.h>... yes
checking for uint32_t in <stdint.h>... yes
checking for library containing socket... none required
checking for library containing inet_addr... none required
checking for timer_create in -lrt... yes
checking for sin... no
checking for main in -lieee... yes
checking for sched_setscheduler... yes
checking for pthread_create in -lpthread... yes
checking for X... libraries , headers
checking for gethostbyname... yes
checking for connect... yes
checking for remove... yes
checking for shmat... yes
checking for IceConnectionNumber in -lICE... no
checking whether X11 headers are broken... no
checking dvs_clib.h usability... no
checking dvs_clib.h presence... no
checking for dvs_clib.h... no
checking for sv_open in -ldvsoem... no
checking for ./DeckLink/Linux/DeckLinkAPI.h... no
checking for ./DeckLink/Linux/DeckLinkAPIDispatch.cpp... no
checking for main in -lDeckLinkAPI... no
checking how to run the C++ preprocessor... g++ -E
checking BlueVelvet.h usability... no
checking BlueVelvet.h presence... no
checking for BlueVelvet.h... no
checking for BlueVelvetFactory in -lBlueVelvet64... no
checking for hanc_decoder_ex in -lBlueANCUtils64... no
checking for VideoMasterHD_Core.h... no
checking for VideoMasterHD_Sdi.h... no
checking for VideoMasterHD_Sdi_Audio.h... no
checking SDL/SDL.h usability... no
checking SDL/SDL.h presence... no
checking for SDL/SDL.h... no
SDL.h not found.
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for RTSP... no
checking for /usr/include/liveMedia/liveMedia.hh... yes
checking for RESIZE... no
checking for BLANK... no
checking GL/glew.h usability... no
checking GL/glew.h presence... no
checking for GL/glew.h... no
checking for GL/gl.h... no
checking for GL/glx.h... no
configure: WARNING: OpenGL headers (gl.h, glx.h) not found or not usable.
checking for GL/glx.h... (cached) no
checking for GL/gl.h... (cached) no
checking for glBindTexture in -lGL... no
checking for glXCreateNewContext in -lGL... no
checking for XCreateWindow in -lX11... yes
checking X11/Xlib.h usability... yes
checking X11/Xlib.h presence... yes
checking for X11/Xlib.h... yes
checking X11/Xutil.h usability... yes
checking X11/Xutil.h presence... yes
checking for X11/Xutil.h... yes
checking for XGetImage in -lX11... yes
checking for XFixesGetCursorImage in -lXfixes... no
checking X11/extensions/Xfixes.h usability... no
checking X11/extensions/Xfixes.h presence... no
checking for X11/extensions/Xfixes.h... no
checking for nvcc... no
checking for LIBGPUJPEG... no
checking for main in -lsail... no
checking for main in -lsail... (cached) no
checking for /usr/local/sage/include/sail.h... no
checking portaudio.h usability... yes
checking portaudio.h presence... yes
checking for portaudio.h... yes
checking for Pa_GetDeviceCount in -lportaudio... yes
checking jack/jack.h usability... yes
checking jack/jack.h presence... yes
checking for jack/jack.h... yes
checking for jack_client_new in -ljack... yes
checking alsa/asoundlib.h usability... yes
checking alsa/asoundlib.h presence... yes
checking for alsa/asoundlib.h... yes
checking for snd_pcm_open in -lasound... yes
checking for TEXT... no
checking for V4L2... no
checking for LIBAVCODEC... no
checking for LIBAVUTIL... no
checking for CURSES... no
checking for CURSES... no
checking for CRYPTO... yes
checking for AES_ctr128_encrypt... yes
checking for VIDEO_MIX... no
checking for LAVC_HWDEC... no

UltraGrid configuration summary:

  Target ...................... x86_64-unknown-linux-gnu
  Debug output ................ no
  Profiling support ........... no
  IPv6 support ................ yes
  RT priority ................. no
  Standalone modules .......... no
  License ..................... GPLv2
  iHDTV support ............... no
  OpenSSL-libcrypto ........... yes
  CUDA support ................ no (host code compiler: default)
  Library live555 ............. yes
  Syphon ...................... no

  AJA ......................... no
  AV Foundation ............... no
  Bluefish444 ................. no (audio: no)
  DeckLink .................... no
  DirectShow .................. no
  DELTACAST ................... no
  DVS ......................... no
  OpenGL ...................... no
  Quicktime ................... no
  SAGE ........................ no
  SDL ......................... no
  Screen Capture .............. yes
  V4L2 ........................ no
  RTSP Capturer Client ........ no
  SW Video Mix ................ no

  Portaudio ................... yes
  ALSA ........................ yes
  CoreAudio ................... no
  JACK  ....................... yes
  JACK transport .............. no

  Realtime DXT (OpenGL) ....... no
  JPEG ........................ no
  JPEG to DXT ................. no
  CUDA DXT .................... no
  UYVY dummy compression ...... no
  Libavcodec .................. no

  blank capture filter ........ no
  resize capture filter ....... no
  text postprocess and filter . no
  RTSP Server ................. yes
  scale postprocessor ......... no
  testcard extras ............. no
  GPU accelerated LDGM ........ no
  MCU-like video mixer ........ no
  Libavcodec hw decoding ...... no

checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/config.h
config.status: executing depfiles commands

Make Step Error

make
mkdir -p src src/audio src/audio/capture src/audio/codec src/audio/playback src/capture_filter src/compat src/crypto src/hd-rum-translator src/ihdtv src/rtp src/rtsp src/utils src/video_capture src/video_compress src/video_decompress src/video_display src/video_rxtx src/vo_postprocess ag_plugin bin cuda_dxt dxt_compress ldgm/src ldgm/matrix-gen lib lib/ultragrid
touch src/dir-stamp
gcc -std=gnu99 -g -O2 -I. -fPIC -msse4 -pipe -W -Wall -Wcast-qual -Wcast-align -Wbad-function-cast -Wmissing-prototypes -Wmissing-declarations -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment    -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/audio/capture/alsa.c -o src/audio/capture/alsa.o
gcc -std=gnu99 -g -O2 -I. -fPIC -msse4 -pipe -W -Wall -Wcast-qual -Wcast-align -Wbad-function-cast -Wmissing-prototypes -Wmissing-declarations -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment    -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/audio/capture/jack.c -o src/audio/capture/jack.o
gcc -std=gnu99 -g -O2 -I. -fPIC -msse4 -pipe -W -Wall -Wcast-qual -Wcast-align -Wbad-function-cast -Wmissing-prototypes -Wmissing-declarations -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment    -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/audio/capture/portaudio.c -o src/audio/capture/portaudio.o
gcc -std=gnu99 -g -O2 -I. -fPIC -msse4 -pipe -W -Wall -Wcast-qual -Wcast-align -Wbad-function-cast -Wmissing-prototypes -Wmissing-declarations -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment    -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/audio/playback/alsa.c -o src/audio/playback/alsa.o
gcc -std=gnu99 -g -O2 -I. -fPIC -msse4 -pipe -W -Wall -Wcast-qual -Wcast-align -Wbad-function-cast -Wmissing-prototypes -Wmissing-declarations -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment    -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/audio/playback/jack.c -o src/audio/playback/jack.o
g++ -g -O2 -I. -std=gnu++11 -fPIC -msse4 -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment   -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/audio/playback/portaudio.cpp -o src/audio/playback/portaudio.o
g++ -g -O2 -I. -std=gnu++11 -fPIC -msse4 -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment   -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/crypto/openssl_decrypt.cpp -o src/crypto/openssl_decrypt.o
g++ -g -O2 -I. -std=gnu++11 -fPIC -msse4 -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment   -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/crypto/openssl_encrypt.cpp -o src/crypto/openssl_encrypt.o
g++ -g -O2 -I. -std=gnu++11 -fPIC -msse4 -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment   -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/rtsp/BasicRTSPOnlyServer.cpp -o src/rtsp/BasicRTSPOnlyServer.o
g++ -g -O2 -I. -std=gnu++11 -fPIC -msse4 -I/usr/include/groupsock -I/usr/include/liveMedia -I/usr/include/BasicUsageEnvironment -I/usr/include/UsageEnvironment   -g -DHAVE_CONFIG_H -DPATH_PREFIX='"/usr/local"' -DLIB_DIR='"/usr/local/lib"' -Wall -Wextra -Wpointer-arith -DGF_BITS=16 -D_GNU_SOURCE -Isrc -I. -I./src -I./test -Idxt_compress -I./speex-1.2rc1/include  -c src/rtsp/BasicRTSPOnlySubsession.cpp -o src/rtsp/BasicRTSPOnlySubsession.o
src/rtsp/BasicRTSPOnlySubsession.cpp: In member function ‘virtual void BasicRTSPOnlySubsession::startStream(unsigned int, void*, void (*)(void*), void*, short unsigned int&, unsigned int&, void (*)(void*, u_int8_t), void*)’:
src/rtsp/BasicRTSPOnlySubsession.cpp:243:11: error: ‘struct msg_sender’ has no member named ‘port’
    msgV1->port = ntohs(Vdestination->rtpPort.num());
           ^
src/rtsp/BasicRTSPOnlySubsession.cpp:272:11: error: ‘struct msg_sender’ has no member named ‘port’
    msgA1->port = ntohs(Adestination->rtpPort.num());
           ^
src/rtsp/BasicRTSPOnlySubsession.cpp: In member function ‘virtual void BasicRTSPOnlySubsession::deleteStream(unsigned int, void*&)’:
src/rtsp/BasicRTSPOnlySubsession.cpp:304:11: error: ‘struct msg_sender’ has no member named ‘port’
    msgV1->port = rtp_port;
           ^
src/rtsp/BasicRTSPOnlySubsession.cpp:334:11: error: ‘struct msg_sender’ has no member named ‘port’
    msgA1->port = rtp_port_audio;
           ^
make: *** [src/rtsp/BasicRTSPOnlySubsession.o] Error 1

I test in linux ubuntu.

Can anybody help me?

Body:
This is because the live555 release you are using in not compatible with ultragrid.

This code that doesnot build changed in this commit ea1971c116dddee7a7cffe014c9a6d98f8d969fd, that indicate the live555 release to use.

In order to build with the recommanded release of live you can proceed like this :

git clone https://github.com/xanview/live555
pushd live555
git checkout 35c375c
./genMakefile linux
make PREFIX=/tmp/live install
popd
./configure --enable-rtsp-server --with-live555=/tmp/live
make


问:
LINQ to Entities does not recognize the method 'System.String ToString()' method in MVC 4
I'm working with MVC 4 and I have to update my database using Code First Migrations.  What I'm trying to do is to select records from a database table, and insert them into a dropdown list where the user can select one.

I have an error that I don't understand:

LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression.

Controller:

```<code>  public ActionResult Addnew()
        {
            var dba = new DefaultConnection();
            var query = dba.blob.Select(c => new SelectListItem
            {
                Value = c.id.ToString(),
                Text = c.name_company,
                Selected = c.id.Equals(3)
            });
            var model = new Companylist
            {
                xpto = query.AsEnumerable()
            };

            return View(model);
        }
</code>```

答:
Following is how I do it to display as a SelectList.

```<code> public List<BlobEntity> GetBlobs()
    {
        List<BlobEntity> blobs = null;
        using (var db = new MyDBEntities())
        {
            blobs = (from b in db.blobs
                     where b.id > 0 //Example filter
                     select new BlobEntity
                     {
                         ID = b.id,
                         CompanyName = b.name_company
                     }
                     ).ToList();

        }
        return blobs;
    }

   public static SelectList GetBlobsSelectList()
    {
        MyBL theBL = new MyBL();
        List<BlobEntity> blobEntites = theBL.GetBlobs();
        var listItems = blobEntites
             .Select(x => new SelectListItem { Text = x.CompanyName,
                                                Value = x.ID.ToString()
                                             })
             .ToList();
        SelectList blobsSelectList = new SelectList(listItems.AsEnumerable(), "Value", "Text");
        return blobsSelectList;
    }

   public class BlobEntity
   {
       public int ID { get; set; }
       public string CompanyName { get; set; }
   }
</code>```

The current accepted answer (by @VarunK) is okay if you are selecting all records and all columns. However, if that is not the case, it is better to do a projection with required columns and records before applying ToList().

Take a look at Why LINQ to Entities does not recognize the method 'System.String ToString()?.

Other references: Problem with converting int to string in Linq to entities

Body:
I'm working with MVC 4 and I have to update my database using Code First Migrations.  What I'm trying to do is to select records from a database table, and insert them into a dropdown list where the user can select one.

I have an error that I don't understand:

LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression.

Controller:

  public ActionResult Addnew()
        {
            var dba = new DefaultConnection();
            var query = dba.blob.Select(c => new SelectListItem
            {
                Value = c.id.ToString(),
                Text = c.name_company,
                Selected = c.id.Equals(3)
            });
            var model = new Companylist
            {
                xpto = query.AsEnumerable()
            };

            return View(model);
        }

Body:
Following is how I do it to display as a SelectList.

 public List<BlobEntity> GetBlobs()
    {
        List<BlobEntity> blobs = null;
        using (var db = new MyDBEntities())
        {
            blobs = (from b in db.blobs
                     where b.id > 0 //Example filter
                     select new BlobEntity
                     {
                         ID = b.id,
                         CompanyName = b.name_company
                     }
                     ).ToList();

        }
        return blobs;
    }

   public static SelectList GetBlobsSelectList()
    {
        MyBL theBL = new MyBL();
        List<BlobEntity> blobEntites = theBL.GetBlobs();
        var listItems = blobEntites
             .Select(x => new SelectListItem { Text = x.CompanyName,
                                                Value = x.ID.ToString()
                                             })
             .ToList();
        SelectList blobsSelectList = new SelectList(listItems.AsEnumerable(), "Value", "Text");
        return blobsSelectList;
    }

   public class BlobEntity
   {
       public int ID { get; set; }
       public string CompanyName { get; set; }
   }

The current accepted answer (by @VarunK) is okay if you are selecting all records and all columns. However, if that is not the case, it is better to do a projection with required columns and records before applying ToList().

Take a look at Why LINQ to Entities does not recognize the method 'System.String ToString()?.

Other references: Problem with converting int to string in Linq to entities


问:
Gradle Build Error
I just started using Android Studio and I was trying to run my app until Gradle build error popped out:

```<code>Executing tasks: [:app:generateDebugSources, :app:mockableAndroidJar, :app:generateDebugAndroidTestSources]
</code>```

Please help!
thanks

答:
Check the gradle console at the botton right as it has more output than the Event log.

Maybe the problem is that you just have to update gradle to the last version, and it should solve the problem.

If it does not work, take a look at that answer in this post

Hope it helps you!
vote answer if it does!

Title: Gradle Build Error

Body:
I just started using Android Studio and I was trying to run my app until Gradle build error popped out:

Executing tasks: [:app:generateDebugSources, :app:mockableAndroidJar, :app:generateDebugAndroidTestSources]

Please help!
thanks


问:
How to pass only Error messages from Model to Controller (Mongoose)?
I'm building my node.js api and want to pass on the callback only messages about errors. Now I need to have a deal with object like this

```<code>{
    "success": false,
    "msg": {
        "errors": {
            "email": {
                "message": "test@tes is not a valid email!",
                "name": "ValidatorError",
                "properties": {
                    "type": "user defined",
                    "message": "{VALUE} is not a valid email!",
                    "path": "email",
                    "value": "test@tes"
                },
                "kind": "user defined",
                "path": "email",
                "value": "test@tes"
            },
            "username": {
                "message": "The Username is not long enough",
                "name": "ValidatorError",
                "properties": {
                    "type": "user defined",
                    "message": "The Username is not long enough",
                    "path": "username",
                    "value": "te"
                },
                "kind": "user defined",
                "path": "username",
                "value": "te"
            }
        },
        "_message": "Users validation failed",
        "name": "ValidationError"
    }
}
</code>```

Here is my code
userModel.js

```<code>/* Custom Validation */
const validator = (v)=> {
    return v.length > 5;
};
/* END of Custom Validation */

const UserSchema = new Schema({
        username: {
            type: String,
            validate: [
                validator,
                'The Username is not long enough'
            ],
            required: [true, 'The Username is required'],
            unique: true,
            lowercase: true
        },
        password: {
            type: String,
            required: [true, 'The Password is required']
        },
        email: {
            type: String,
            validate: [
                (v)=> { return /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(v)},
                '{VALUE} is not a valid email!'
            ],
            lowercase: true,
            required: true
        },
        role: {
            type: [{
                type: String,
                enum: ['user', 'manager', 'admin']
            }],
            default: ['user']
        },
        team: {
            type: [{
                type: String,
                enum: ['IHLO', 'ADULT&SH', 'IPJ', 'ISD', '']
            }],
            default: ['']
        },
        created_date: {
            type: Date,
            default: Date.now
        },

    });

    UserSchema.pre('save', ...

    UserSchema.methods.comparePassword = ...

    module.exports = mongoose.model('Users', UserSchema);
**userController.js**

    / Register new user
    exports.signup = (req, res)=> {

        let new_user = new User(req.body);
        new_user.save((err, new_user)=> {
            if (err)
                return res.json({success: false, msg: err});
            res.json({success: true, msg: `Successful created new user ${new_user.username}.`});
        });
    };
</code>```

Of course I can make a function on the frontend that search for 'message' keys but for some records it could be more than 100 errors. Is it anyway how I can do it and do not pass the redundancy data?

答:
projections

User.find({}, {messages: 1})
or

User.find({},'messages')

the second parameter is projection mongoose api

I think you can also do the User.find({},'messages -_id') to leave out _id but if you are using object you can do {_id : 0}

If you want to filter out objects with error messages:

you could use .lean() to make a real js object

do something like

```<code>User.find({}).lean()
.then(users =>{
  user.filter(e => e.name == "ValidationError")
})
</code>```

Haven't tested

Body:
I'm building my node.js api and want to pass on the callback only messages about errors. Now I need to have a deal with object like this

{
    "success": false,
    "msg": {
        "errors": {
            "email": {
                "message": "test@tes is not a valid email!",
                "name": "ValidatorError",
                "properties": {
                    "type": "user defined",
                    "message": "{VALUE} is not a valid email!",
                    "path": "email",
                    "value": "test@tes"
                },
                "kind": "user defined",
                "path": "email",
                "value": "test@tes"
            },
            "username": {
                "message": "The Username is not long enough",
                "name": "ValidatorError",
                "properties": {
                    "type": "user defined",
                    "message": "The Username is not long enough",
                    "path": "username",
                    "value": "te"
                },
                "kind": "user defined",
                "path": "username",
                "value": "te"
            }
        },
        "_message": "Users validation failed",
        "name": "ValidationError"
    }
}

Here is my code
userModel.js

/* Custom Validation */
const validator = (v)=> {
    return v.length > 5;
};
/* END of Custom Validation */

const UserSchema = new Schema({
        username: {
            type: String,
            validate: [
                validator,
                'The Username is not long enough'
            ],
            required: [true, 'The Username is required'],
            unique: true,
            lowercase: true
        },
        password: {
            type: String,
            required: [true, 'The Password is required']
        },
        email: {
            type: String,
            validate: [
                (v)=> { return /^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i.test(v)},
                '{VALUE} is not a valid email!'
            ],
            lowercase: true,
            required: true
        },
        role: {
            type: [{
                type: String,
                enum: ['user', 'manager', 'admin']
            }],
            default: ['user']
        },
        team: {
            type: [{
                type: String,
                enum: ['IHLO', 'ADULT&SH', 'IPJ', 'ISD', '']
            }],
            default: ['']
        },
        created_date: {
            type: Date,
            default: Date.now
        },

    });

    UserSchema.pre('save', ...

    UserSchema.methods.comparePassword = ...

    module.exports = mongoose.model('Users', UserSchema);
**userController.js**

    / Register new user
    exports.signup = (req, res)=> {

        let new_user = new User(req.body);
        new_user.save((err, new_user)=> {
            if (err)
                return res.json({success: false, msg: err});
            res.json({success: true, msg: `Successful created new user ${new_user.username}.`});
        });
    };

Of course I can make a function on the frontend that search for 'message' keys but for some records it could be more than 100 errors. Is it anyway how I can do it and do not pass the redundancy data?

Body:
projections

User.find({}, {messages: 1})
or

User.find({},'messages')

the second parameter is projection mongoose api

I think you can also do the User.find({},'messages -_id') to leave out _id but if you are using object you can do {_id : 0}

If you want to filter out objects with error messages:

you could use .lean() to make a real js object

do something like

User.find({}).lean()
.then(users =>{
  user.filter(e => e.name == "ValidationError")
})

Haven't tested


问:
Retrofit does not call failure and response.code() is 400
I'm sure there's something wrong with what I'm doing here. Retrofit does not go to failure even if the code that I'm getting is 400. </p>

```<code>        AuthenticationService authService = retrofit.create(AuthenticationService.class);
        Call<ValidateTokenResponseMessage> request = authService.validateToken(token);
        request.enqueue(new Callback<ValidateTokenResponseMessage>() {
            @Override
            public void onResponse(Call<ValidateTokenResponseMessage> call, retrofit2.Response<ValidateTokenResponseMessage> response) {
            // When I try to put a breakpoint here I can see that response.code() is 400.
                ValidateTokenResponseMessage body = response.body();
                if (!body.getValidToken()) {
                    // do success
                }
            }

            @Override
            public void onFailure(Call<ValidateTokenResponseMessage> call, Throwable t) {
                // do failure
            }
        });
</code>```

答:
Callback.onFailure only gets called for exceptions like missing internet connection or invalid https etc.

Invoked when a network exception occurred talking to the server or when an unexpected exception occurred creating the request or processing the response.

To check for errors you have to use Response.isSuccessful()

Returns true if code() is in the range [200..300).

Body:
I'm sure there's something wrong with what I'm doing here. Retrofit does not go to failure even if the code that I'm getting is 400.

        AuthenticationService authService = retrofit.create(AuthenticationService.class);
        Call<ValidateTokenResponseMessage> request = authService.validateToken(token);
        request.enqueue(new Callback<ValidateTokenResponseMessage>() {
            @Override
            public void onResponse(Call<ValidateTokenResponseMessage> call, retrofit2.Response<ValidateTokenResponseMessage> response) {
            // When I try to put a breakpoint here I can see that response.code() is 400.
                ValidateTokenResponseMessage body = response.body();
                if (!body.getValidToken()) {
                    // do success
                }
            }

            @Override
            public void onFailure(Call<ValidateTokenResponseMessage> call, Throwable t) {
                // do failure
            }
        });


问:
Error "Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)"
I've installed Python 3.5 and while running

pip install mysql-python
```
<p>it gives me the following error</p>
<blockquote>
<p>error: Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)</p>
</blockquote>
<p>I have added the following lines to my Path</p>
<pre class="lang-none prettyprint-override"><code>C:\Program Files\Python 3.5\Scripts\;
C:\Program Files\Python 3.5\;

C:\Windows\System32;
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC
</code>```

I have a 64-bit Windows 7 setup on my PC.

What could be the solution for mitigating this error and installing the modules correctly via pip.

答: I had the same issue. Downloading the Build Tools for Visual Studio 2017 worked for me.</p>

Body:
I've installed Python 3.5 and while running

pip install mysql-python

it gives me the following error

error: Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)

I have added the following lines to my Path

C:\Program Files\Python 3.5\Scripts\;
C:\Program Files\Python 3.5\;

C:\Windows\System32;
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC

I have a 64-bit Windows 7 setup on my PC.

What could be the solution for mitigating this error and installing the modules correctly via pip.


问:
How to optimize building speed in visual studio 2008
Could someone give me tips to increase building speed in visual studio 2008?

I have a large project with many module with full source. Every single time it's built, every files are rebuilt, some of them were not changed. Can i prevent these file to be rebuilt?
I turned the property "Enable Minimum rebuild" /Gm on but the compiler threw this warning

```<code>Command line warning D9030 : '/Gm' is incompatible with multiprocessing; ignoring /MP switch
</code>```

Every tips to increase building speed will help me much.
Thanks,

答:
One simple way is to compile in debug mode(aka zero optimizations), this of course is only for internal testing.

you can also use precompiled headers* to speed up processing, or break off 'unchanging' segments into static libs, removing those from the recompile.

*with /MP you need to create the precompiled header before doing multiprocess compilation, as /MP can read but not write according to MSDN

Body:
Could someone give me tips to increase building speed in visual studio 2008?

I have a large project with many module with full source. Every single time it's built, every files are rebuilt, some of them were not changed. Can i prevent these file to be rebuilt?
I turned the property "Enable Minimum rebuild" /Gm on but the compiler threw this warning

Command line warning D9030 : '/Gm' is incompatible with multiprocessing; ignoring /MP switch

Every tips to increase building speed will help me much.
Thanks,


问:
Very New To Power Shell, Object Reference Error In Short Script
First off, I'm very new to Power Shell (and scripting in general). I'm getting my feet wet by trying to write a simple script that will get all users with a certain manager, and then set them to a new manager. Currently, we do this manually in our AD and it can be time consuming.

However, with the script below I keep getting the following error:

Set-ADUser : Object reference not set to an instance of an object.
At line:6 char:2
+     Set-ADUser -Identity $users -Manager jane.manager

Here is my short script:

```<code>$users=Get-ADUser -Identity john.manager -Properties directreports | Select directreports

ForEach ($user in $users) {

    Set-ADUser -Identity $users -Manager jane.manager
}
</code>```

答:
There are two problems with your current script.

```<code>$users=Get-ADUser -Identity john.manager -Properties directreports | Select directreports
                                                   #                   ^
                                                   #                   |
                                                   # this creates 1 object with a
                                                   # "directreports" property
</code>```

Set-ADUser won't be able to recognize such an object. Since you want references to the directReports objects, expand it to a list of values with the ExpandProperty parameter:

```<code>$users=Get-ADUser -Identity john.manager -Properties directreports | Select -ExpandProperty directreports
</code>```

The second problem appears to be a typo, inside the loop you refer to the $users collection that you're looping over, instead of the current $user:

```<code>$users=Get-ADUser -Identity john.manager -Properties directreports | Select -ExpandProperty directreports

foreach($user in $users){
    Set-ADUser -Identity $user -Manager jane.manager
}
</code>```

If you're unsure what you're doing, heed Charlie Joynt's advice and use the -WhatIf switch parameter with Set-ADUser:

```<code>Set-ADUser -Identity $user -Manager jane.manager -WhatIf
</code>```

Instead of making any changes, Set-ADUser will tell you what it was going to do, had you omitted -WhatIf

Body:
First off, I'm very new to Power Shell (and scripting in general). I'm getting my feet wet by trying to write a simple script that will get all users with a certain manager, and then set them to a new manager. Currently, we do this manually in our AD and it can be time consuming.

However, with the script below I keep getting the following error:

Set-ADUser : Object reference not set to an instance of an object.
At line:6 char:2
+     Set-ADUser -Identity $users -Manager jane.manager

Here is my short script:

$users=Get-ADUser -Identity john.manager -Properties directreports | Select directreports

ForEach ($user in $users) {

    Set-ADUser -Identity $users -Manager jane.manager
}

Body:
There are two problems with your current script.

$users=Get-ADUser -Identity john.manager -Properties directreports | Select directreports
                                                   #                   ^
                                                   #                   |
                                                   # this creates 1 object with a
                                                   # "directreports" property

Set-ADUser won't be able to recognize such an object. Since you want references to the directReports objects, expand it to a list of values with the ExpandProperty parameter:

$users=Get-ADUser -Identity john.manager -Properties directreports | Select -ExpandProperty directreports

The second problem appears to be a typo, inside the loop you refer to the $users collection that you're looping over, instead of the current $user:

$users=Get-ADUser -Identity john.manager -Properties directreports | Select -ExpandProperty directreports

foreach($user in $users){
    Set-ADUser -Identity $user -Manager jane.manager
}

If you're unsure what you're doing, heed Charlie Joynt's advice and use the -WhatIf switch parameter with Set-ADUser:

Set-ADUser -Identity $user -Manager jane.manager -WhatIf

Instead of making any changes, Set-ADUser will tell you what it was going to do, had you omitted -WhatIf


问:
Is it actually possible to store and process individual UTF-8 characters on C ? If so, how?
I've written a program in C that breaks words down into syllables, segments and letters. It's working well with ASCII characters but I want to make versions that work for the IPA and Arabic too.

I'm having massive problems saving and performing functions on individual characters. My editor and console are both set up to UTF-8 and can display Arabic text fine if I save it as a char*, but when I try to print wchars they display random punctuation marks.

My program needs to be able to recognise an individual UTF-8 character in order to work. For example, for the word 'though' it stores 't' as syllable[1]segment[1]letter[1], h as syllable[1]segment[1]letter[2] etc. I want to be able to do the same for non-ASCII characters.

I've spent basically the whole day researching unicode and trying out different methods and I can't get any of them to let me store an Arabic character as a character.

I'm not sure if I've just made some stupid syntax errors along the way, if I've completely misunderstood the whole concept, or if it actually just isn't possible to do what I want in C and I should just give up and try another language...

I would massively, massively, massively appreciate any help you can offer! I'm pretty new to programming, but unicode is completely instrumental to my work so I want to work out how to do it from the beginning.

My understanding of how unicode works (in case that's where I'm going wrong):

I type some text into my editor. My editor encodes it according to the encoding I have set. So if I set it to UFT-8 it will encode the Arabic letter ب with the 2 byte sequence 0xd8 0xab which indicates the code point U+0628.

I compile it, breaking down 0xd8 0xab into the binary 11011000 10101000.

I run it on the command prompt. The command prompt interprets the text according to the encoding I have set, so if I set it to UFT-8 it should interpret 11011000 10101000 as the code point U+0628. Unicode algorithms also tell it which version of U+0628 to display to me, as the character has different shapes depending on where it is in the word. As the character is alone it will show me the standalone version ب

My understanding of the ways I can process unicode in C:

Option A - Use single bytes encoded as UTF-8 (http://www.nubaria.com/en/blog/?p=289)

Use single bytes encoded as UTF-8. Leave all my datatypes as chars and char arrays and only type ASCII characters in my code. If I absolutely have to hard code a unicode character enter it as an array in the format:

```<code>    const char kChineseSampleText[] = "\xe4\xb8\xad\xe6\x96\x87";
</code>```

My problems with this:

I need to manipulate individual characters

Having to type Arabic characters as code points is going to render my code completely unreadable and slow me down immensely.

Option B - Use wchar and friends (http://icu-project.org/docs/papers/unicode_wchar_t.html)

Swap using chars for wchars, which hold 2 to 4 bytes depending on the compiler. String functions like strlen will not work as they are expecting characters to be one byte, but there are w functions like  wprintf I can use instead.

My problem with this:

I can’t get wchars to print Arabic characters at all! I can get them to print English letters fine, but Arabic characters just pull through as random punctuation marks.

I've tried inputing the unicode code point as well as the actual Arabic character and I've tried printing them both to the console and to a UTF-8 encoded text file and I get the same result, even though both the console and the text file display Arabic text if entered as a char*. I've included my code at the end.

(It’s worth saying here that I am aware that a lot of people think wchars are bad because they aren’t very portable and because they take up extra space for ASCII characters. But at this stage, neither of those things are really a worry for me - I’m just writing the program to run on my own computer and the program will only be processing short strings.)

Option C - Use external libraries

I've read in various comments that external libraries are the way to go so I've tried:

C programming library

http://www.cprogramming.com/tutorial/unicode.html suggests replacing all chars with unsigned long integers and using special functions for iterating through strings etc. The site even provides a sample library to download.

My problem:

While I can set the character to be an unsigned long integer I can’t print it out, because the printf and wprintf functions don’t work, and neither does the library provided on the website (I think maybe the library was designed for Linux? Some of the datatypes are invalid and amending them didn't work either)

ICU library

My problem:

I downloaded the ICU library, but when I was looking into how to use it I saw that functionality such as the characterIterator is not available for use in C (http://userguide.icu-project.org/strings). Being able to iterate through characters is completely fundamental to what I need to do, so I don't think the library will work for me.

My code

```<code>#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
#include <locale.h>
#include <string.h>

int main ()
{
wchar_t unicode = L'\xd8ac';
wchar_t arabic = L'ب';
wchar_t number = 0x062c;

FILE* f;
f = fopen("unitest.txt","w");
char* string = "ايه الاخبار";

//printf - works

printf("printf - literal arabic character is \"م\"\n");
fprintf(f,"printf - literal arabic character is \"م\"\n");

printf("printf - char* string is \"%s\"\n",string);
fprintf(f,"printf - char* string is \"%s\"\n",string);

//wprintf  - english - works

wprintf(L"wprintf - literal english char is \"%C\"\n\n", L't');
fwprintf(f,L"wprintf - literal english char is \"%C\"\n\n", L't');

//wprintf - arabic - doesnt work

wprintf(L"wprintf - unicode wchar_t is \"%C\"\n", unicode);
fwprintf(f,L"wprintf - unicode wchar_t is \"%C\"\n", unicode);

wprintf(L"wprintf - unicode number wchar_t is \"%C\"\n", number);
fwprintf(f,L"wprintf - unicode number wchar_t is \"%C\"\n", number);

wprintf(L"wprintf - arabic wchar_t is \"%C\"\n", arabic);
fwprintf(f,L"wprintf - arabic wchar_t is \"%C\"\n", arabic);

wprintf(L"wprintf - literal arabic character is \"%C\"\n",L'ت');
fwprintf(f,L"wprintf - literal arabic character is \"%C\"\n",L'ت');

wprintf(L"wprintf - literal arabic character in string is \"م\"\n\n");
fwprintf(f,L"wprintf - literal arabic character in string is \"م\"\n\n");

fclose(f);

return 0;
}
</code>```

Output file

```<code>printf - literal arabic character is "م"
printf - char* string is "ايه الاخبار"
wprintf - literal english char is "t"

wprintf - unicode wchar_t is "�"
wprintf - unicode number wchar_t is ","
wprintf - arabic wchar_t is "("
wprintf - literal arabic character is "*"
wprintf - literal arabic character in string is ""
</code>```

I'm using Windows 10, Notepad++ and  MinGW.

Edit
This got marked as a duplicate of Light C Unicode Library but I don't think it really answers my question. I've downloaded the library and had a look at and you can call me stupid if you like, but I'm really new to programming and I don't understand most of the code in the library, so it's hard for me to work out how I can use it achieve what I want. I searched the library for a print function and couldn't find one...

I just want to save a UTF-8 character and then print it out again! Do I really need to install an entire library to do that? I would just really appreciate someone taking pity on me and telling me in baby terms how I can do it... People keep saying I should use uint_32 or something instead of wchar - but how do I then print those datatypes? Can I do it with wprintf?!

答:
C and UTF-8 are still getting to know each other.  In-other-words, IMO, C support for UTF-8 is scant.

Is it ... possible to store and process individual UTF-8 characters ...?

First step is to make certain "ايه الاخبار" is a UTF-8 encoded string.  C supports this explicitly with u8"ايه الاخبار".

A UTF-8 string is a sequence of char.  Each 1 to 4 char represents a Unicode character.  A Unicode character needs at least 21-bits for encoding.  Yet OP does not needs to convert a portion of string[] into a Unicode character as much as wants to segment that string on UTF-8 boundaries.  This is readily found by looking for UTF-8 continuation bytes.

The following forms a 1 Unicode character encoded as a UTF-8 string with the accompanying terminating null character.  Then that short string is printed.

```<code>char* string = u8"ايه الاخبار";
for (char *s = string; *s; ) {
  printf("<");
  char u[5];
  char *p = u;
  *p++ = *s++;
  if ((*s & 0xC0) == 0x80) *p++ = *s++;
  if ((*s & 0xC0) == 0x80) *p++ = *s++;
  if ((*s & 0xC0) == 0x80) *p++ = *s++;
  *p = 0;
  printf("%s", u);
  printf(">\n");
}
</code>```

With the output viewed with a UTF8 aware screen:

```<code><ا>
<ي>
<ه>
< >
<ا>
<ل>
<ا>
<خ>
<ب>
<ا>
<ر>
</code>```

Body:
I've written a program in C that breaks words down into syllables, segments and letters. It's working well with ASCII characters but I want to make versions that work for the IPA and Arabic too.

I'm having massive problems saving and performing functions on individual characters. My editor and console are both set up to UTF-8 and can display Arabic text fine if I save it as a char*, but when I try to print wchars they display random punctuation marks.

My program needs to be able to recognise an individual UTF-8 character in order to work. For example, for the word 'though' it stores 't' as syllable[1]segment[1]letter[1], h as syllable[1]segment[1]letter[2] etc. I want to be able to do the same for non-ASCII characters.

I've spent basically the whole day researching unicode and trying out different methods and I can't get any of them to let me store an Arabic character as a character.

I'm not sure if I've just made some stupid syntax errors along the way, if I've completely misunderstood the whole concept, or if it actually just isn't possible to do what I want in C and I should just give up and try another language...

I would massively, massively, massively appreciate any help you can offer! I'm pretty new to programming, but unicode is completely instrumental to my work so I want to work out how to do it from the beginning.

My understanding of how unicode works (in case that's where I'm going wrong):

I type some text into my editor. My editor encodes it according to the encoding I have set. So if I set it to UFT-8 it will encode the Arabic letter ب with the 2 byte sequence 0xd8 0xab which indicates the code point U+0628.

I compile it, breaking down 0xd8 0xab into the binary 11011000 10101000.

I run it on the command prompt. The command prompt interprets the text according to the encoding I have set, so if I set it to UFT-8 it should interpret 11011000 10101000 as the code point U+0628. Unicode algorithms also tell it which version of U+0628 to display to me, as the character has different shapes depending on where it is in the word. As the character is alone it will show me the standalone version ب

My understanding of the ways I can process unicode in C:

Option A - Use single bytes encoded as UTF-8 (http://www.nubaria.com/en/blog/?p=289)

Use single bytes encoded as UTF-8. Leave all my datatypes as chars and char arrays and only type ASCII characters in my code. If I absolutely have to hard code a unicode character enter it as an array in the format:

    const char kChineseSampleText[] = "\xe4\xb8\xad\xe6\x96\x87";

My problems with this:

I need to manipulate individual characters

Having to type Arabic characters as code points is going to render my code completely unreadable and slow me down immensely.

Option B - Use wchar and friends (http://icu-project.org/docs/papers/unicode_wchar_t.html)

Swap using chars for wchars, which hold 2 to 4 bytes depending on the compiler. String functions like strlen will not work as they are expecting characters to be one byte, but there are w functions like  wprintf I can use instead.

My problem with this:

I can’t get wchars to print Arabic characters at all! I can get them to print English letters fine, but Arabic characters just pull through as random punctuation marks.

I've tried inputing the unicode code point as well as the actual Arabic character and I've tried printing them both to the console and to a UTF-8 encoded text file and I get the same result, even though both the console and the text file display Arabic text if entered as a char*. I've included my code at the end.

(It’s worth saying here that I am aware that a lot of people think wchars are bad because they aren’t very portable and because they take up extra space for ASCII characters. But at this stage, neither of those things are really a worry for me - I’m just writing the program to run on my own computer and the program will only be processing short strings.)

Option C - Use external libraries

I've read in various comments that external libraries are the way to go so I've tried:

C programming library

http://www.cprogramming.com/tutorial/unicode.html suggests replacing all chars with unsigned long integers and using special functions for iterating through strings etc. The site even provides a sample library to download.

My problem:

While I can set the character to be an unsigned long integer I can’t print it out, because the printf and wprintf functions don’t work, and neither does the library provided on the website (I think maybe the library was designed for Linux? Some of the datatypes are invalid and amending them didn't work either)

ICU library

My problem:

I downloaded the ICU library, but when I was looking into how to use it I saw that functionality such as the characterIterator is not available for use in C (http://userguide.icu-project.org/strings). Being able to iterate through characters is completely fundamental to what I need to do, so I don't think the library will work for me.

My code

#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
#include <locale.h>
#include <string.h>

int main ()
{
wchar_t unicode = L'\xd8ac';
wchar_t arabic = L'ب';
wchar_t number = 0x062c;

FILE* f;
f = fopen("unitest.txt","w");
char* string = "ايه الاخبار";

//printf - works

printf("printf - literal arabic character is \"م\"\n");
fprintf(f,"printf - literal arabic character is \"م\"\n");

printf("printf - char* string is \"%s\"\n",string);
fprintf(f,"printf - char* string is \"%s\"\n",string);

//wprintf  - english - works

wprintf(L"wprintf - literal english char is \"%C\"\n\n", L't');
fwprintf(f,L"wprintf - literal english char is \"%C\"\n\n", L't');

//wprintf - arabic - doesnt work

wprintf(L"wprintf - unicode wchar_t is \"%C\"\n", unicode);
fwprintf(f,L"wprintf - unicode wchar_t is \"%C\"\n", unicode);

wprintf(L"wprintf - unicode number wchar_t is \"%C\"\n", number);
fwprintf(f,L"wprintf - unicode number wchar_t is \"%C\"\n", number);

wprintf(L"wprintf - arabic wchar_t is \"%C\"\n", arabic);
fwprintf(f,L"wprintf - arabic wchar_t is \"%C\"\n", arabic);

wprintf(L"wprintf - literal arabic character is \"%C\"\n",L'ت');
fwprintf(f,L"wprintf - literal arabic character is \"%C\"\n",L'ت');

wprintf(L"wprintf - literal arabic character in string is \"م\"\n\n");
fwprintf(f,L"wprintf - literal arabic character in string is \"م\"\n\n");

fclose(f);

return 0;
}

Output file

printf - literal arabic character is "م"
printf - char* string is "ايه الاخبار"
wprintf - literal english char is "t"

wprintf - unicode wchar_t is "�"
wprintf - unicode number wchar_t is ","
wprintf - arabic wchar_t is "("
wprintf - literal arabic character is "*"
wprintf - literal arabic character in string is ""

I'm using Windows 10, Notepad++ and  MinGW.

Edit
This got marked as a duplicate of Light C Unicode Library but I don't think it really answers my question. I've downloaded the library and had a look at and you can call me stupid if you like, but I'm really new to programming and I don't understand most of the code in the library, so it's hard for me to work out how I can use it achieve what I want. I searched the library for a print function and couldn't find one...

I just want to save a UTF-8 character and then print it out again! Do I really need to install an entire library to do that? I would just really appreciate someone taking pity on me and telling me in baby terms how I can do it... People keep saying I should use uint_32 or something instead of wchar - but how do I then print those datatypes? Can I do it with wprintf?!

Body:
C and UTF-8 are still getting to know each other.  In-other-words, IMO, C support for UTF-8 is scant.

Is it ... possible to store and process individual UTF-8 characters ...?

First step is to make certain "ايه الاخبار" is a UTF-8 encoded string.  C supports this explicitly with u8"ايه الاخبار".

A UTF-8 string is a sequence of char.  Each 1 to 4 char represents a Unicode character.  A Unicode character needs at least 21-bits for encoding.  Yet OP does not needs to convert a portion of string[] into a Unicode character as much as wants to segment that string on UTF-8 boundaries.  This is readily found by looking for UTF-8 continuation bytes.

The following forms a 1 Unicode character encoded as a UTF-8 string with the accompanying terminating null character.  Then that short string is printed.

char* string = u8"ايه الاخبار";
for (char *s = string; *s; ) {
  printf("<");
  char u[5];
  char *p = u;
  *p++ = *s++;
  if ((*s & 0xC0) == 0x80) *p++ = *s++;
  if ((*s & 0xC0) == 0x80) *p++ = *s++;
  if ((*s & 0xC0) == 0x80) *p++ = *s++;
  *p = 0;
  printf("%s", u);
  printf(">\n");
}

With the output viewed with a UTF8 aware screen:

<ا>
<ي>
<ه>
< >
<ا>
<ل>
<ا>
<خ>
<ب>
<ا>
<ر>